tools-deps

2024-10-29T14:45:09.712109Z

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.
...

dpsutton 2024-10-29T14:48:33.496949Z

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

2024-10-29T14:50:56.249149Z

interesting, that creates a slightly different classpath than -Stree

2024-10-29T14:52:10.557499Z

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

dpsutton 2024-10-29T14:52:25.283829Z

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

dpsutton 2024-10-29T14:52:35.151959Z

Oh I had it wrong. Sorry

2024-10-29T14:52:43.669749Z

no worries, i should have noticed

2024-10-29T14:53:38.338399Z

cool, now they're equivalent, thank you

2024-10-29T14:54:01.510369Z

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

dpsutton 2024-10-29T14:54:16.528109Z

It’s calling a separate process

dpsutton 2024-10-29T14:54:27.552279Z

It is weird until you recognize that

dpsutton 2024-10-29T14:54:47.035729Z

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

2024-10-29T14:55:43.159259Z

but how does -Stree work then?

dpsutton 2024-10-29T14:55:53.317009Z

Same process

dpsutton 2024-10-29T14:56:22.717409Z

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

dpsutton 2024-10-29T14:57:13.800169Z

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

dpsutton 2024-10-29T14:57:35.442689Z

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

2024-10-29T14:58:06.794929Z

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

dpsutton 2024-10-29T15:01:00.124429Z

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

seancorfield 2024-10-29T15:02:01.391109Z

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

👍 1
2024-10-29T15:12:42.014389Z

interesting

2024-10-29T15:12:52.249299Z

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

dpsutton 2024-10-29T16:15:21.583339Z

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

dpsutton 2024-10-29T18:30:21.130689Z

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

dpsutton 2024-10-29T18:38:09.236769Z

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

dpsutton 2024-10-29T18:52:54.952769Z

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