tools-deps

borkdude 2024-09-11T14:08:34.496649Z

I was testing out this:

$ clj -T:deps clojure.tools.deps/find-latest-version :lib io.github.babashka/sci.nrepl
found versions:  nil
Any idea why no version was found?

Alex Miller (Clojure team) 2024-09-11T14:20:30.933909Z

versions are based on tags

lread 2024-09-11T14:20:36.914679Z

Just tried it here:

$ clj -T:deps clojure.tools.deps/find-latest-version :lib io.github.babashka/sci.nrepl
Downloading: org/clojure/tools.deps.cli/0.11.72/tools.deps.cli-0.11.72.pom from central
Downloading: org/clojure/tools.deps/0.21.1445/tools.deps-0.21.1445.pom from central
Downloading: org/clojure/tools.deps.cli/0.11.72/tools.deps.cli-0.11.72.jar from central
Downloading: org/clojure/tools.deps/0.21.1445/tools.deps-0.21.1445.jar from central
Cloning: 
found versions:  nil
The cloning line makes me think it is assuming this is a git dep? But there are no tags https://github.com/babashka/sci.nrepl/tags And it did not find the clojars dep: https://clojars.org/io.github.babashka/sci.nrepl (which I think is what you were expecting to happen)

borkdude 2024-09-11T14:21:46.647239Z

This library is available on clojars though

borkdude 2024-09-11T14:22:00.401229Z

yeah

borkdude 2024-09-11T14:22:21.663359Z

I thought I had made tags too, but apparently not and it seems this is an genuine edge case

Alex Miller (Clojure team) 2024-09-11T14:24:05.115299Z

I thought it actually looked for both

Alex Miller (Clojure team) 2024-09-11T14:24:17.978669Z

tools.build is another example that has both with same groupId/artifactId

lread 2024-09-11T14:25:29.987809Z

$ clj -T:deps clojure.tools.deps/find-latest-version :lib io.github.clojure/tools.build
found versions:  (#:git{:tag 0.0.1, :sha 7631db2} #:git{:tag 0.0.2, :sha cad58d9} #:git{:tag 0.0.3, :sha 1c46cfd} #:git{:tag 0.0.4, :sha ab0fe98} #:git{:tag v0.0.5, :sha 004a192} #:git{:tag v0.0.6, :sha c50c286} #:git{:tag v0.0.7, :sha c947e7c} #:git{:tag v0.1.0, :sha 6fd58ef} #:git{:tag v0.1.1, :sha 52607b8} #:git{:tag v0.1.2, :sha 88dc72a} #:git{:tag v0.1.3, :sha 688245e} #:git{:tag v0.1.4, :sha 5993438} #:git{:tag v0.1.5, :sha 622e8a0} #:git{:tag v0.1.6, :sha 1e7c019} #:git{:tag v0.1.7, :sha fc2e1f8} #:git{:tag v0.1.8, :sha 1fcbe86} #:git{:tag v0.1.9, :sha 6736c83} #:git{:tag v0.2.0, :sha ef094d6} #:git{:tag v0.2.1, :sha 68c4946} #:git{:tag v0.2.2, :sha 1dd9f6f} #:git{:tag v0.3.0, :sha ec5b8ff} #:git{:tag v0.4.0, :sha 655423e} #:git{:tag v0.4.1, :sha af8acb8} #:git{:tag v0.5.0, :sha 3247680} #:git{:tag v0.5.1, :sha 599be6c} #:git{:tag v0.6.0, :sha bff9726} #:git{:tag v0.6.1, :sha d7b64db} #:git{:tag v0.6.2, :sha 7ef409b} #:git{:tag v0.6.3, :sha 166b920} #:git{:tag v0.6.4, :sha ea76dff} #:git{:tag v0.6.5, :sha a0c3ff6} #:git{:tag v0.6.6, :sha 4d41c26} #:git{:tag v0.6.7, :sha 8cca4f4} #:git{:tag v0.6.8, :sha d79ae84} #:git{:tag v0.7.0, :sha 16eddbf} #:git{:tag v0.7.1, :sha 13f0fec} #:git{:tag v0.7.2, :sha 0361dde} #:git{:tag v0.7.3, :sha 2699924} #:git{:tag v0.7.4, :sha ac442da} #:git{:tag v0.7.5, :sha 34727f7} #:git{:tag v0.7.6, :sha 3549b5f} #:git{:tag v0.7.7, :sha 1474ad6} #:git{:tag v0.8.0, :sha e3e3532} #:git{:tag v0.8.1, :sha 7d40500} #:git{:tag v0.8.2, :sha ba1a2bf} #:git{:tag v0.8.3, :sha 0d20256} #:git{:tag v0.8.4, :sha 8c3cd69} #:git{:tag v0.8.5, :sha 9c738da} #:git{:tag v0.9.0, :sha 8c93e0c} #:git{:tag v0.9.1, :sha 27ff8a4} #:git{:tag v0.9.2, :sha fe6b140} #:git{:tag v0.9.3, :sha e537cd1} #:git{:tag v0.9.4, :sha 76b78fe} #:git{:tag v0.9.5, :sha 24f2894} #:git{:tag v0.9.6, :sha 8e78bcc} #:git{:tag v0.10.0, :sha 3a2c484} #:git{:tag v0.10.1, :sha 5e3b8f3} #:git{:tag v0.10.3, :sha 15ead66} #:git{:tag v0.10.4, :sha 31388ff} #:git{:tag v0.10.5, :sha 2a21b7a})

lread 2024-09-11T14:27:25.215739Z

$ clj --version
Clojure CLI version 1.12.0.1479

Alex Miller (Clojure team) 2024-09-11T14:28:19.926209Z

that ... is not what I expect it to look like :)

1
lread 2024-09-11T14:30:11.744329Z

Oh wait.

Alex Miller (Clojure team) 2024-09-11T14:30:25.315799Z

oh, this is calling into the internal function

lread 2024-09-11T14:30:37.895709Z

$ clj -X:deps find-versions :lib io.github.clojure/tools.build
{:git/tag "v0.9.4", :git/sha "76b78fe"}
{:git/tag "v0.9.5", :git/sha "24f2894"}
{:git/tag "v0.9.6", :git/sha "8e78bcc"}
{:git/tag "v0.10.0", :git/sha "3a2c484"}
{:git/tag "v0.10.1", :git/sha "5e3b8f3"}
{:git/tag "v0.10.3", :git/sha "15ead66"}
{:git/tag "v0.10.4", :git/sha "31388ff"}
{:git/tag "v0.10.5", :git/sha "2a21b7a"}

Alex Miller (Clojure team) 2024-09-11T14:30:44.885459Z

yes

lread 2024-09-11T14:31:55.585749Z

$ clj -X:deps find-versions :lib io.github.babashka/sci.nrepl 
Downloading: io/github/babashka/sci.nrepl/maven-metadata.xml from clojars
{:mvn/version "0.0.1"}
{:mvn/version "0.0.2"}

borkdude 2024-09-11T14:33:51.491969Z

sorry my bad then, I was looking at the implementation of clojure.repl.deps to include it in bb

borkdude 2024-09-11T14:34:34.037729Z

and there I saw something like this:

(invoke-tool {:tool-alias :deps
                                  :fn 'clojure.tools.deps/find-latest-version
                             :args {:lib lib}})
which I thought I could invoke at the command like in the OP

lread 2024-09-11T14:35:19.663009Z

But we did discover that find-versions favors the git deps if available (over maven deps)... so maybe that's useful info?

Alex Miller (Clojure team) 2024-09-11T16:32:28.361609Z

I was probably using that example to test a tool function that returned data vs one that did stdout

Alex Miller (Clojure team) 2024-09-11T16:34:29.684899Z

If someone wants to make an ask question for that case where a dep is both maven and git, I’m happy to reconsider that case

borkdude 2024-09-11T16:50:39.439409Z

@alexmiller Not sure what "example" you are referring to but I was looking at this code: https://github.com/clojure/clojure/blob/13a2f67b91ab81cd109ea3152fce1ae76d212453/src/clj/clojure/repl/deps.clj#L80

Alex Miller (Clojure team) 2024-09-11T16:53:39.659069Z

Sorry, I misread that (doing too many things at the same time)

borkdude 2024-09-11T16:57:23.483349Z

same here

Alex Miller (Clojure team) 2024-09-11T16:59:18.206709Z

There are two different “flavors” of tool function - ones that take a map and return a value (like find-latest-version, and the ones that support add-libs). invoke-tool is designed to work against one of those by default using the https://clojure.org/reference/clojure_cli#function_protocol. The other flavor are functions designed to work at the CLI (which has no return value) and the function communicates a result on stdout (like find-version). These are also supported by invoke-tool, but certainly more cumbersome (thinking about an additional wrapper there).

Alex Miller (Clojure team) 2024-09-11T17:00:50.032149Z

Depending on your context of use (programmatic or CLI) one of these function styles is probably better

lread 2024-09-11T19:32:26.790179Z

I can raise the ask about preferring git deps vs maven deps.

borkdude 2024-09-11T19:45:31.547119Z

sounds good!