tools-deps

vemv 2024-02-15T09:17:00.307339Z

What's a good way of getting the computed :paths for a set of aliases? I'm seeking for XXX here which would mean "print the computed deps.edn contents after applying these aliases"

clojure -A:dev:test XXX | jet --thread-first :paths

borkdude 2024-02-15T09:19:11.450919Z

It wouldn't surprise me if the basis contained the effective deps.edn

borkdude 2024-02-15T09:20:03.095269Z

but currently the CLI doesn't print the basis. -Sbasis might be a nice option for this. There is an issue for this at https://github.com/borkdude/deps.clj/issues/122 - but wondering if the official CLI has opinions about this

👍 1
vemv 2024-02-15T09:22:19.395849Z

Thanks! I was surprised not to find something like -Sbasis, that had me questioning my own sanity/eyesight

Alex Miller (Clojure team) 2024-02-15T13:32:37.582819Z

Yeah, nothing for that at the moment, feel free to add to ask.clojure

👍 1
Alex Miller (Clojure team) 2024-02-15T13:33:13.666989Z

The basis of course is a file in your cpcache so it’s just printing that

đź‘€ 1
vemv 2024-02-15T13:34:30.193019Z

Will ask :) A file is tempting but considering that it's a function of the aliases, it can feel fragile for end users?

borkdude 2024-02-15T13:34:38.866639Z

where is it printing that file?

borkdude 2024-02-15T13:40:02.130459Z

I know the tools jar is putting that file in .cpcache but is there a (formal) way to get the current .cpcache hash / basis file printed by the CLI?

Alex Miller (Clojure team) 2024-02-15T13:53:28.059609Z

I mean, implementing this would just be printing that file. There is no such functionality now but would be happy to add it

borkdude 2024-02-15T13:54:23.579819Z

yeah, that would be cool and fix @vemv’s question and the open issue with deps.clj posted by @cfleming

borkdude 2024-02-15T14:00:46.107619Z

thanks. I posted two suggestions, either add the cache hash to -Sdescribe, or add a -Sbasis option. FWIW 🪙

Alex Miller (Clojure team) 2024-02-15T14:05:22.344229Z

You can find the hash via -Sverbose btw, but will add -Sbasis

borkdude 2024-02-15T14:08:23.021689Z

ah yeah, -Sverbose, but it's harder to parse than just EDN

cfleming 2024-02-15T18:54:02.463199Z

That would be super useful for me, and I think resolve that outstanding issue. @borkdude Sorry I haven’t had a chance to look at that yet, perhaps waiting will just make the problem go away 🙂

cfleming 2024-02-15T18:55:17.114109Z

I’ll check my code today to see if that would work for Cursive.

borkdude 2024-02-15T19:07:08.032239Z

that = ?

cfleming 2024-02-15T19:07:36.951809Z

The -Sbasis fix.

cfleming 2024-02-15T19:08:31.906489Z

I think that’s actually the only thing I need the paths in that issue for, but I’ll have to check.

borkdude 2024-02-15T19:09:56.481929Z

and would you require -Sbasis to output EDN directly or the path to the file?

cfleming 2024-02-15T19:11:50.946479Z

Either would be fine, but (having not thought it through very carefully yet) I think that EDN probably makes more sense and would be useful for more tools. But the EDN is just a slurp away given the path, so either would work for me.

borkdude 2024-02-15T19:13:17.873029Z

would it be useful to have programmatic access to the hash as well (vs the output that is now in -Sverbose)?

cfleming 2024-02-15T19:13:46.649539Z

Again, I’d have to check, but I believe the only thing I use that for is accessing the basis.

borkdude 2024-02-15T19:13:53.560899Z

k

Alex Miller (Clojure team) 2024-02-15T19:30:15.403029Z

I do not consider the hash normative in any way and would not want to pretend it something you should care about

👍 1
Alex Miller (Clojure team) 2024-02-15T19:30:47.933449Z

I've tried hard to keep that in the domain of the CLI script and out of tools.deps world

borkdude 2024-02-15T19:31:00.272219Z

yeah, the hash would just give access to anything you'd be interested in inside of .cpcache for the combination of relevant arguments, but I guess that's also an impl detail

cfleming 2024-02-15T19:31:27.805769Z

Yes, I definitely feel like I’m fishing around in the implementation at the moment.

borkdude 2024-02-15T19:31:30.810159Z

the basis probably contains all we would ever need 🤞

Alex Miller (Clojure team) 2024-02-15T19:32:30.486359Z

having thought about it more, prob more interested in something like clj -X:deps basis than clj -Sbasis but I don't think that matters for this purpose

Alex Miller (Clojure team) 2024-02-15T19:33:16.800689Z

the difference here in caching may be important though as the former would leverage caching but the latter wouldn't. does this matter?

borkdude 2024-02-15T19:33:51.885249Z

I think it would be helpful if a -Sbasis call with the same arguments would not invoke a JVM again

👍 1
cfleming 2024-02-15T19:34:59.242039Z

Yes, definitely, I would assume that it would just return the cached version if that exists (assuming -Sforce isn’t used.

👍 1
cfleming 2024-02-15T19:39:44.370599Z

Ok, looking at my code, I definitely need the basis, and either a path or EDN would be fine. I also return the path to the installed tools jar and the install dir, but I just use those to extract the system deps.edn to the install path so I have it on the file system. Some other way of obtaining the system deps.edn file would be useful too so I don’t have to do that.

borkdude 2024-02-15T19:43:07.060189Z

-Sverbose gives:

config_paths = /opt/homebrew/Cellar/clojure/1.11.1.1273/deps.edn /Users/borkdude/.clojure/deps.edn deps.edn
not sure if that is inside the basis as well

borkdude 2024-02-15T19:43:21.305209Z

it's not fun to parse the -Sverbose output if you can have it as EDN as well

cfleming 2024-02-15T19:47:17.843059Z

Oh, I didn’t realise the system deps was already extracted to the file system. But yeah, I’ve avoided parsing -Sverbose output so far.

Alex Miller (Clojure team) 2024-02-15T19:58:22.260359Z

there is an api call you make in tools.deps to get the root deps

Alex Miller (Clojure team) 2024-02-15T19:59:09.172389Z

that config_paths above is actually lying a bit - the root deps.edn there is not the one being used (although it exists and should be the same)

cfleming 2024-02-15T20:00:03.277449Z

Right, the actual file is extracted as a resource IIRC. What I’ve been doing is extracting the resource and writing it to install-dir if it doesn’t exist there.

cfleming 2024-02-15T20:01:02.826429Z

IIRC under deps.clj that file is not extracted, but perhaps I checked before tools.deps got called to do the extraction.

borkdude 2024-02-15T20:01:44.798399Z

I remember vaguely that there was some logic in the bash CLI clj script which I also implemented in deps.clj to copy some .edn file to the install dir, is that what you are referring to?

Alex Miller (Clojure team) 2024-02-15T20:02:06.646579Z

that's the user deps.edn, which is effectively empty

Alex Miller (Clojure team) 2024-02-15T20:02:25.323689Z

or the tools install

Alex Miller (Clojure team) 2024-02-15T20:02:36.242889Z

yeah, that installs the tools tool

Alex Miller (Clojure team) 2024-02-15T20:03:11.927809Z

in any case, none of this is relevant to the root deps which ultimately comes from the tools.deps jar

cfleming 2024-02-15T20:06:34.446779Z

I thought the config-paths might be in the basis, but they don’t seem to be.

cfleming 2024-02-15T20:08:43.353139Z

Would it be a good idea to put them there? Then I think -Sbasis would do everything I need without any internal implementation fishing, which I would be very happy about 🙂

Alex Miller (Clojure team) 2024-02-15T20:25:08.744999Z

well, there is no path for the root deps

Alex Miller (Clojure team) 2024-02-15T20:25:23.533409Z

using the CLI, the only path for project.clj is the "./project.clj"

Alex Miller (Clojure team) 2024-02-15T20:25:46.123459Z

user deps is more complicated, but all of these have existing api calls in tools.deps

Alex Miller (Clojure team) 2024-02-15T20:28:03.267679Z

the deps config sources WILL be in the :basis-config if they are something other than the defaults

Alex Miller (Clojure team) 2024-02-15T20:28:25.777479Z

(which they never are for root or project)

Alex Miller (Clojure team) 2024-02-15T20:32:06.579319Z

:basis-config is the same map of params you can pass to all the :deps alias programs and https://clojure.github.io/tools.deps/#clojure.tools.deps/create-basis