Fork me on GitHub
#tools-deps
<
2024-02-15
>
vemv09:02:00

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

borkdude09:02:11

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

borkdude09:02:03

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
vemv09:02:19

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

Alex Miller (Clojure team)13:02:37

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

👍 1
Alex Miller (Clojure team)13:02:13

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

👀 1
vemv13:02:30

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

borkdude13:02:38

where is it printing that file?

borkdude13:02:02

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)13:02:28

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

borkdude13:02:23

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

borkdude14:02:46

thanks. I posted two suggestions, either add the cache hash to -Sdescribe (or add the full path to the basis file), or add a -Sbasis option. FWIW 🪙

Alex Miller (Clojure team)14:02:22

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

borkdude14:02:23

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

cfleming18:02:02

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

cfleming18:02:17

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

cfleming19:02:36

The -Sbasis fix.

cfleming19:02:31

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

borkdude19:02:56

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

cfleming19:02:50

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.

borkdude19:02:17

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

cfleming19:02:46

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

Alex Miller (Clojure team)19:02:15

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)19:02:47

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

borkdude19:02:00

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

cfleming19:02:27

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

borkdude19:02:30

the basis probably contains all we would ever need 🤞

Alex Miller (Clojure team)19:02:30

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)19:02:16

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

borkdude19:02:51

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

👍 1
cfleming19:02:59

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

👍 1
cfleming19:02:44

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.

borkdude19:02:07

-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

borkdude19:02:21

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

cfleming19:02:17

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)19:02:22

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

Alex Miller (Clojure team)19:02:09

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)

cfleming20:02:03

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.

cfleming20:02:02

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

borkdude20:02:44

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)20:02:06

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

Alex Miller (Clojure team)20:02:36

yeah, that installs the tools tool

Alex Miller (Clojure team)20:02:11

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

cfleming20:02:34

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

cfleming20:02:43

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)20:02:08

well, there is no path for the root deps

Alex Miller (Clojure team)20:02:23

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

Alex Miller (Clojure team)20:02:46

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

Alex Miller (Clojure team)20:02:03

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

Alex Miller (Clojure team)20:02:25

(which they never are for root or project)

Alex Miller (Clojure team)20:02:06

: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