tools-deps

dnolen 2024-09-06T14:33:13.731489Z

is there anything in for deps that's analogous to :upgrade false in Lein?

2024-09-06T14:57:44.899009Z

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

seancorfield 2024-09-06T20:55:08.370299Z

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?

seancorfield 2024-09-09T14:58:04.646699Z

@alexmiller ?

Alex Miller (Clojure team) 2024-09-09T15:09:50.123699Z

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)

Alex Miller (Clojure team) 2024-09-09T15:11:11.337509Z

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}})

Alex Miller (Clojure team) 2024-09-09T15:32:54.202859Z

oh, the docs are wrong in that link!

seancorfield 2024-09-09T16:17:20.645579Z

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.

Alex Miller (Clojure team) 2024-09-09T16:17:45.772719Z

Yeah, I don’t know what’s happening there

seancorfield 2024-09-09T16:18:10.053509Z

(at least that explains why :clojure.exec/invoke is appearing -- but it is passed :fn instead of true?)

Alex Miller (Clojure team) 2024-09-09T16:42:38.830549Z

yeah

seancorfield 2024-09-09T16:43:41.328709Z

antq exits with System/exit -- would that affect how invoke-tool behaves?

Alex Miller (Clojure team) 2024-09-09T16:48:31.244629Z

if it wasn't done printing to stdout, then maybe

seancorfield 2024-09-09T16:49:22.178809Z

For -X (or -T invocation), it really shouldn't call System/exit anyway. I'll open a ticket there...

Alex Miller (Clojure team) 2024-09-09T16:56:03.745839Z

yeah, it has to be that the envelope is not on the stream so it just doesn't know what happened

seancorfield 2024-09-09T16:57:58.649829Z

https://github.com/liquidz/antq/issues/261

seancorfield 2024-09-06T20:59:06.514689Z

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).

seancorfield 2024-09-06T21:13:47.334019Z

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?

seancorfield 2024-09-06T21:14:19.748809Z

(`build/hello` just has (println "Hello, World!") in it)

seancorfield 2024-09-20T23:56:49.805949Z

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.

jumar 2024-09-06T04:04:18.414629Z

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/)

seancorfield 2024-09-06T04:09:49.481019Z

Does that git repo have deps.edn or pom.xml? It needs one of those to be used as a git dep.

seancorfield 2024-09-06T04:11:57.438749Z

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.

jumar 2024-09-06T04:12:46.349649Z

Ah, I didn't think about that. It only has project.clj. Thanks!