is there anything in for deps that's analogous to :upgrade false in Lein?
What does upgrade false do? I don't see it in the sample project.clj for lein that documents most options. It looks like maybe it is an option for the lein-ancient plugin, antq which I guess is what you would use to replace lein-ancient has https://github.com/liquidz/antq/blob/main/doc/exclusions.adoc
I have some questions about invoke-tool in 1.12:
I have antq installed: clojure -Ttools install-latest :lib com.github.liquidz/antq :as antq
I run this at the command-line line:
(~/clojure)-(!2038)-> clojure -Tantq outdated
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
[##################################################] 1/1
All dependencies are up-to-date.
The first three lines are stderr, the last two stdout. I can get it to produce EDN:
(~/clojure)-(!2039)-> clojure -Tantq outdated :reporter '"edn"'
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
()
and we can see the stdout only here:
(~/clojure)-(!2040)-> clojure -Tantq outdated :reporter '"edn"' 2> /dev/null
()
So I would expect the following to work in a REPL:
(~/clojure)-(!2041)-> clj
Clojure 1.12.0
user=> ((requiring-resolve 'clojure.tools.deps.interop/invoke-tool)
{:debug true :preserve-envelope true
:tool-name "antq" :fn 'outdated :args {:reporter "edn"}})
but I get an exception with only stderr output:
args [outdated {:reporter edn, :clojure.exec/invoke :fn}]
Invoking: clojure -Tantq -
Execution error (ExceptionInfo) at clojure.tools.deps.interop/invoke-tool (interop.clj:83).
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
The exit status of the tool is 0 and reading the invoke-tool source, I would expect it to be able to read the stdout and report that. What am I missing?Tools invoked by invoke-tool use the https://clojure.org/reference/clojure_cli#function_protocol - note the key :clojure.exec/out there. the envelope itself is what is returned on stdout in this mode (which may optionally include :out)
so I think you want:
((requiring-resolve 'clojure.tools.deps.interop/invoke-tool)
{:debug true :preserve-envelope true
:tool-name "antq" :fn 'outdated :args {:reporter "edn", :clojure.exec/out :capture}})oh, the docs are wrong in that link!
Well, that works for the simple case (`build/hello`):
user=> (invoke-tool {:debug true :preserve-envelope true :tool-alias :build :fn 'hello :args {:name "edn" :clojure.exec/out :capture}})
args [hello {:name edn, :clojure.exec/out :capture, :clojure.exec/invoke :fn}]
Invoking: clojure -T:build -
{:tag :ret, :val "nil", :ms 0, :out "Hello, edn!\n"}
but still doesn't work for the antq outdated case:
user=> (invoke-tool {:debug true :preserve-envelope true :tool-name "antq" :fn 'outdated :args {:clojure.exec/out :capture}})
args [outdated #:clojure.exec{:out :capture, :invoke :fn}]
Invoking: clojure -Tantq -
Execution error (ExceptionInfo) at clojure.tools.deps.interop/invoke-tool (interop.clj:83).
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details. Yeah, I don’t know what’s happening there
(at least that explains why :clojure.exec/invoke is appearing -- but it is passed :fn instead of true?)
yeah
antq exits with System/exit -- would that affect how invoke-tool behaves?
if it wasn't done printing to stdout, then maybe
For -X (or -T invocation), it really shouldn't call System/exit anyway. I'll open a ticket there...
yeah, it has to be that the envelope is not on the stream so it just doesn't know what happened
Looking at the source https://github.com/clojure/clojure/blob/master/src/clj/clojure/tools/deps/interop.clj#L74-L86 I would expect if-let [envelope (edn/read-string (slurp out))] to take the truthy path and return the envelope (since I have :preserve-envelope true).
I guess this is why:
(~/clojure)-(!2046)-> clj
Clojure 1.12.0
user=> ((requiring-resolve 'clojure.tools.deps.interop/invoke-tool)
{:debug true :preserve-envelope true
:tool-alias :build :fn 'hello :args {:reporter "edn"}})
args [hello {:reporter edn, :clojure.exec/invoke :fn}]
Invoking: clojure -T:build -
{:tag :ret, :val "nil", :ms 0}
user=>
(~/clojure)-(!2047)-> clojure -T:build hello '{:reporter "edn"}'
Hello, World!
The stdout of the invoked tool is not retrievable?(`build/hello` just has (println "Hello, World!") in it)
As a follow-up to this, it was due to antq calling System/exit in -X/`-T` mode and that has now been fixed, and I can run tool as expected with invoke-tool now.
How can I use a private git repo as git style dependency in deps.edn? I've tried both HTTPS url and ssh-style URL but none of that works.
myorg/artifact {:git/url "
:git/sha "c7afa8f0298ceb244b65aac22cc72fee6ae36c3a"}
;; or
myorg/artifact {:git/url "git@github.com:myorg/artifact.git"
:git/sha "c7afa8f0298ceb244b65aac22cc72fee6ae36c3a"}
This is the error I get
clj -M:dev:dev-repl:cider-repl
Error building classpath. Manifest file not found for myorg/artifact in coordinate #:git{:url "git@github.com:myorg/artifact.git", :sha "c7afa8f0298ceb244b65aac22cc72fee6ae36c3a"}
This works on command line
git clone git@github.com:myorg/artifact.git
NOTE: I use 1password for managing ssh keys (https://developer.1password.com/docs/ssh/agent/)Does that git repo have deps.edn or pom.xml? It needs one of those to be used as a git dep.
If it doesn't have either of those, you can use the :deps/manifest option to treat it as if it has an empty deps.edn file -- https://clojure.org/reference/deps_edn#deps_deps_manifest -- but you'll need to specify any project dependencies yourself, explicitly.
Ah, I didn't think about that. It only has project.clj. Thanks!