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?versions are based on tags
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)This library is available on clojars though
yeah
I thought I had made tags too, but apparently not and it seems this is an genuine edge case
I thought it actually looked for both
tools.build is another example that has both with same groupId/artifactId
$ 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})$ clj --version
Clojure CLI version 1.12.0.1479that ... is not what I expect it to look like :)
Oh wait.
oh, this is calling into the internal function
$ 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"}yes
$ 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"}sorry my bad then, I was looking at the implementation of clojure.repl.deps to include it in bb
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 OPBut we did discover that find-versions favors the git deps if available (over maven deps)... so maybe that's useful info?
I was probably using that example to test a tool function that returned data vs one that did stdout
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
@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
Sorry, I misread that (doing too many things at the same time)
same here
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).
Depending on your context of use (programmatic or CLI) one of these function styles is probably better
I can raise the ask about preferring git deps vs maven deps.
sounds good!
Done! https://ask.clojure.org/index.php/14106/consider-fact-that-clj-x-deps-find-versions-prefers-git-deps