tools-deps 2024-10-29

i've run into a discrepancy between -Stree and -X:deps tree.

noah@Noahs-MacBook-Pro ~/personal/splint  [main ≡]
$ clojure -A:dev:test -Stree
org.clojure/data.json 2.5.0
org.clojure/clojure 1.11.4
...
vs
noah@Noahs-MacBook-Pro ~/personal/splint  [main ≡]
$ clojure -A:dev:test -X:deps tree
Exception in thread "main" Syntax error macroexpanding at (noahtheduke/splint/dev.clj:1:1).
...
Caused by: java.io.FileNotFoundException: Could not locate noahtheduke/splint/config__init.class, noahtheduke/splint/config.clj or noahtheduke/splint/config.cljc on classpath.
...

i think you need clj -X:deps tree :aliases '["dev" "test"]'

interesting, that creates a slightly different classpath than -Stree

oh, :aliases '[:dev :test]' does it

I think there are two processes in play for the X version. That’s why the aliases are passed as arguments and not just operating on the program you call at the cli

Oh I had it wrong. Sorry

no worries, i should have noticed

cool, now they're equivalent, thank you

odd that you can't use -A for the -X call

It’s calling a separate process

It is weird until you recognize that

At which point it’s obvious that they are aliases that must affect the sub process, not the main one

but how does -Stree work then?

Same process

I mean it runs in the same process versus starting a child

I imagine this was all changed to handle that if you can only see the deps involved based on how you were started, you are necessarily a bit limited. It’s better to take alias as information and compute instead of just relying on your own invocation

I could be super wrong but that’s how I understand it

you're probably right. the clojure script is pretty complex, i'm no good at bash lol, so i'm not entirely sure how clojure itself is started up

It’s not that, it’s the deps program that invokes a subprocess

The :deps alias uses :replace-deps, like you're using -T.

👍 1

i can't quite follow how this all works, but at least i have a solution

ok so i was mistaken about it being passed to a separate process. It’s just that it creates an explicit basis and you have to tell it which aliases to use

👍 1
Alex Miller (Clojure team) 2024-10-29T18:29:43.542339Z

it is actually a separate process but probably not in the way you're thinking

oh interesting. i thought i vaguely remembered that. but when i looked up the source it was just hitting clojure.tools.deps.api so i thought i had misremembered it

Alex Miller (Clojure team) 2024-10-29T18:30:25.395829Z

-Stree runs in the pre process (separate JVM) that calculates the classpath.

Alex Miller (Clojure team) 2024-10-29T18:30:44.719719Z

-A affects that

Alex Miller (Clojure team) 2024-10-29T18:31:18.355609Z

with -X:deps tree you are calculating the classpath of the deps program in the preprocess, then running the program in the main process, which also calculates the classpath

where is the boundary between the two processes? I didn’t see it offhand (if it’s easy to point to)

Alex Miller (Clojure team) 2024-10-29T18:52:27.302429Z

the clojure script will (if no basis cached or needed for other reasons like -Stree) run clojure.tools.deps.script.make-classpath2 to create the basis and other files. then it runs a program as defined by -M, -X, -T

ahhh. i see. i had my mental model a bit wrong. Thanks!

Alex Miller (Clojure team) 2024-10-29T18:53:04.823789Z

cat `which clojure
`

Alex Miller (Clojure team) 2024-10-29T18:53:26.626109Z

if you read that, you should see the places where java is invoked