This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-24
Channels
- # announcements (22)
- # babashka (33)
- # babashka-sci-dev (161)
- # beginners (25)
- # calva (57)
- # cider (6)
- # clara (6)
- # clerk (14)
- # clj-kondo (24)
- # clojars (10)
- # clojure (65)
- # clojure-austin (1)
- # clojure-conj (2)
- # clojure-europe (23)
- # clojure-miami (3)
- # clojure-nl (3)
- # clojure-norway (3)
- # clojure-uk (3)
- # clojurescript (28)
- # cursive (24)
- # datomic (136)
- # emacs (38)
- # graalvm (29)
- # graphql (3)
- # introduce-yourself (8)
- # jackdaw (4)
- # jobs-discuss (9)
- # malli (5)
- # nbb (36)
- # off-topic (11)
- # pathom (58)
- # polylith (2)
- # practicalli (1)
- # re-frame (5)
- # reagent (11)
- # releases (1)
- # remote-jobs (8)
- # sci (15)
- # shadow-cljs (31)
- # slack-help (2)
- # spacemacs (11)
- # sql (7)
- # tools-build (9)
ive noticed that when i use :local/root deps with relative paths in bb.edn and use it from another place via --config, the local paths are resolved relative to my pwd and not the bb.edn. is it due to deps.clj being used there and its an expected behaviour? if yes, should it be changed as we say --config <file> Replacing bb.edn with file. Relative paths are resolved relative to file.
?
i can take a stab at it hopefully soon
i should do it in the bb repo right?
I wonder how it interacts with the cache, I don’t think the working dir is reflected in there as the cache is simply a hash of deps.edn
deps.clj already has https://github.com/borkdude/deps.clj/blob/e9318a759628221c48b9259bc8885d4aee1d7262/src/borkdude/deps.clj#L41 so I think it would be just a matter or setting that to the correct dir
instead of rewriting the paths after the fact here:
https://github.com/babashka/babashka/blob/64dcb3335d6eb35bc8a59e36b5d6104ebd46e1fe/src/babashka/impl/deps.clj#L63
I think we can just bind the *dir*
var to the deps-root directory and then it will work for both paths and local/roots
so use with-bindings
+ cond->
here and add *dir*
when deps-root is there
https://github.com/babashka/babashka/blob/64dcb3335d6eb35bc8a59e36b5d6104ebd46e1fe/src/babashka/impl/deps.clj#L93
got it
so would the user need to specify the deps-root as well here?
got it. yeah i meant should i need to explicitly specify --deps-root
looking into the tests
or fix it here: https://github.com/borkdude/deps.clj/blob/e9318a759628221c48b9259bc8885d4aee1d7262/src/borkdude/deps.clj#L571
good points, will get back to it soon. now my local stuff is working fine, should be better 😄
I hope absolutizing both files is a good solution
user=> (binding [deps/*exit-fn* identity deps/*dir* ".."] (deps/-main "-M" "-e" "(System/getProperty (str 'user.dir))"))
"/Users/borkdude/dev"
nil
user=> (binding [deps/*exit-fn* identity deps/*dir* "../.."] (deps/-main "-M" "-e" "(System/getProperty (str 'user.dir))"))
"/Users/borkdude"
I can think of one other edge case: in Windows when you invoke the script from another disk drive
yep, this should work:
user=> (binding [deps/*dir* "/C:/foo"] (deps/relativize "/D:/foo/bar"))
#object[sun.nio.fs.UnixPath 0x1d23ff23 "../../D:/foo/bar"]
right, will pull in the changes
tests pass, pushed
i was using the test-utils/bb for a test like:
(testing "relative paths in :deps are relative to bb.edn"
(test-utils/with-config '{:deps {babashka/process {:local/root "./process"}}}
(is (= (str (fs/cwd) "/process/src")
(first
(bb "-e" "(do (require '[babashka.classpath :as cp])
(cp/split-classpath (cp/get-classpath)))"))))))
but the test utils passes a --deps-root
as .
in https://github.com/babashka/babashka/blob/master/test/babashka/test_utils.clj#L52
is this test okay as it resolves to the root of the bb repo and not the location of the bb.edn or a different util method without the --deps-root is to be used?or i guess there is a better testing suggestion in general? 😅
also not sure if that (str (fs/cwd) "/process/src")
works as expected on windows
this doesn't change the deps-root right, so how does this test the change that the test is for?
I'd look for a test that tests the deps-root feature and add another test like that but with a local/root the refers to a relative dir
cant seem to find a test for deps-root, the only mentions of it in context of tests i can see are: • https://github.com/babashka/babashka/blob/master/test/babashka/test_utils.clj#L52 • https://github.com/babashka/babashka/blob/master/test/babashka/test_utils.clj#L92 any pointers of where could i find it? i thought https://github.com/babashka/babashka/blob/master/test/babashka/bb_edn_test.clj could have it
well, adding that too 😎
compared to the https://github.com/babashka/babashka/pull/1478#issuecomment-1407181862 from mac, linux has a very different error:
lein test babashka.bb-edn-test
=== deps-root-tests
Error building classpath. ../../home/lispyclouds/code/repos/babashka (Is a directory)
java.io.FileNotFoundException: ../../home/lispyclouds/code/repos/babashka (Is a directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:158)
at java.base/java.io.FileReader.<init>(FileReader.java:75)
at $slurp_edn.invokeStatic(io.clj:42)
at clojure.tools.deps$slurp_edn_map$fn__664.invoke(deps.clj:39)
at clojure.tools.deps$slurp_edn_map.invokeStatic(deps.clj:39)
at clojure.tools.deps$slurp_deps.invokeStatic(deps.clj:96)
at clojure.tools.deps.script.make_classpath2$read_deps.invokeStatic(make_classpath2.clj:163)
at clojure.tools.deps.script.make_classpath2$run.invokeStatic(make_classpath2.clj:174)
at clojure.tools.deps.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:228)
at clojure.tools.deps.script.make_classpath2$_main.doInvoke(make_classpath2.clj:195)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.main$main_opt.invokeStatic(main.clj:514)
at clojure.main$main_opt.invoke(main.clj:510)
at clojure.main$main.invokeStatic(main.clj:664)
at clojure.main$main.doInvoke(main.clj:616)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:40)
Tests failed.
some level of deps-root testing is there on my PR though
its the same test im running here too, not sure if there is a better way to test this that doenst depend on where its running
this code here: https://github.com/babashka/babashka/pull/1478#issuecomment-1407181862
im running this in the same deftest i added to the PR
didnt push it yet as it breaks
pushed
I'm getting:
lein test babashka.bb-edn-test
=== deps-root-tests
Error building classpath. Local lib local/dep not found: /Users/borkdude/dev/babashka/local-dep
that's weird, is the deps-root in the temp dir for you in https://github.com/babashka/babashka/blob/rel-deps/src/babashka/impl/deps.clj#L96 ?
this error should come without my changes
the issue is that the tests set a default config and deps-root so I made this change in the test code:
args (cond-> args
(and *bb-edn-path* (not (some #(= "--config" %) args)))
(->> (list* "--config" *bb-edn-path*))
(and *bb-edn-path* (not (some #(= "--deps-root" %) args)))
(->> (list* "--deps-root" ".")))
which should be okay right? as long as the deps root is passed to the deps/dir with my changes?
You can run that test with: lein do clean, test :only babashka.bb-edn-test/unix-task-test
Now I'm also getting:
Error building classpath. Can't create directory: /private/Users/borkdude/.clojure/.cpcache
Ah, this might make sense now, maybe a thing in deps.clj where it tries to write the cache directory but it shouldn't take *dir*
into account hereyeah i suppose theres gonna be differing behaviour due to this
I don't see any reference to *dir*
here in deps.clj:
config-dir
(or (*getenv-fn* "CLJ_CONFIG")
(when-let [xdg-config-home (*getenv-fn* "XDG_CONFIG_HOME")]
(.getPath (io/file xdg-config-home "clojure")))
(.getPath (io/file (home-dir) ".clojure")))
user-cache-dir
(or (*getenv-fn* "CLJ_CACHE")
(when-let [xdg-config-home (*getenv-fn* "XDG_CACHE_HOME")]
(.getPath (io/file xdg-config-home "clojure")))
(.getPath (io/file config-dir ".cpcache")))
oh I see:
cache-dir
(if (.exists (io/file deps-edn))
(.getPath (io/file *dir* ".cpcache"))
user-cache-dir)
hehe finally 😛
there's quite a few knobs to be aware about
Can you explain this test to me?
(testing "custom deps-root path"
(let [out (bb "--config" config "--deps-root" "/tmp" "cp")
entries (cp/split-classpath out)]
(is (= 1 (count entries)))
(is (= "/tmp/src" (first entries)))))
oh I get it yes, but you have to make this more cross platform, "/tmp" doesn't work on Windows I think
yeah that was one of my doubts, looking at it now
lein test :only babashka.bb-edn-test/deps-root-test
FAIL in (deps-root-test) (bb_edn_test.clj:498)
custom deps-root path
expected: (= "/tmp/src" (first entries))
actual: (not (= "/tmp/src" "C:\\tmp\\src"))
=== deps-race-condition-test
but this test:
(testing "default deps-root path is same as bb.edn"
(let [out (bb "--config" config "cp")
entries (cp/split-classpath out)]
(is (= (fs/parent f) (fs/parent (first entries))))))
succeeds, but in the tests we always add --deps-root "."
so this test isn't testing what it's supposed tothis was my dilemma too in https://clojurians.slack.com/archives/C02FBBU61A9/p1674842023949889?thread_ts=1674551849.533369&cid=C02FBBU61A9
oh no, this is good since we don't set *bb-edn-path*
in this test, we don't use with-config
so these are the printed args :
("--config" "/var/folders/j9/xmjlcym958b1fr0npsp9msvh0000gn/T/4a86539f-dff2-4c9e-8c4d-f8931232a5902671065622392340497/bb.edn" "cp")
:entries ["/var/folders/j9/xmjlcym958b1fr0npsp9msvh0000gn/T/4a86539f-dff2-4c9e-8c4d-f8931232a5902671065622392340497/src"]
looks good to me
should it be set just for this test right?
since in this test you're spitting your own bb.edn and setting config + deps-root yourself
yes the linux error i mentioned above
you can see it in the CI
yeah i mean a not my machine specific error 😅
does it pass for you?
but if you run just this test, does it pass?
interesting, does it only fail on linux somehow then?
but why is it even going to ../../home/circleci/repo
?
yeah, good that i can reproduce this here
it might be good to insert some printlns etc in the deps.clj (use the -debug function, as out and err are captured in the tests)
i was doing it in places til borkdude.deps/deps
is called.
i'll try to dig in a few hours, need to finish off some stuff!
some stuff i found:
deps-edn
is an empty string in deps clj and its being set to config-project
and (relativize config-project)
gives that weird path
due to https://github.com/borkdude/deps.clj/blob/master/src/borkdude/deps.clj#L807 the surrounding shell cmd is failing
so somehow it cant find the deps.edn in the *dir*
?
ah so *dir*
is the dir where the local-dep
dir is and that has the deps.edn. so it cant find it
not sure why its different in mac?
brb in some time
you can repro this with:
bb -Sdeps '{:deps {borkdude/deps.clj {:mvn/version "1.11.1.1208"}}}' -m borkdude.deps -Sdeps-file uuuuxx
vs
bb -Sdeps '{:deps {borkdude/deps.clj {:mvn/version "1.11.1.1208"}}}' -m borkdude.deps -Sdeps-file /tmp
I think the -Sdeps-file workaround can be entirely removed now though since we always override deps and paths
checking out the "fixes" in deps
ah yeah
well fun stuff. im happy we found new stuff and had more tests than we started
definitely makes me more comfortable with the codebase now