tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
viesti 2020-09-28T08:49:37.067900Z

humdum, I sometimes get this error in CirleCI while building project:

clojure -A:... -m kaocha.runner analysis
Picked up JAVA_TOOL_OPTIONS: -Dclojure.main.report=stderr -XX:-OmitStackTraceInFastThrow
Cloning: git@github.com:viesti/timbre-json-appender.git
Checking out: git@github.com:viesti/timbre-json-appender.git at 176a32bc5f7311c22b091b9700b5f98c11807774
Error building classpath. class java.util.HashMap$Node cannot be cast to class java.util.HashMap$TreeNode (java.util.HashMap$Node and java.util.HashMap$TreeNode are in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class java.util.HashMap$Node cannot be cast to class java.util.HashMap$TreeNode (java.util.HashMap$Node and java.util.HashMap$TreeNode are in module java.base of loader 'bootstrap')
	at java.base/java.util.HashMap$TreeNode.moveRootToFront(HashMap.java:1882)
	at java.base/java.util.HashMap$TreeNode.treeify(HashMap.java:1998)
	at java.base/java.util.HashMap.treeifyBin(HashMap.java:767)
	at java.base/java.util.HashMap.putVal(HashMap.java:639)
	at java.base/java.util.HashMap.put(HashMap.java:607)
	at java.base/java.util.HashSet.add(HashSet.java:220)
	at org.apache.maven.model.validation.DefaultModelValidator.validateId(DefaultModelValidator.java:847)
	at org.apache.maven.model.validation.DefaultModelValidator.validateEffectiveDependency(DefaultModelValidator.java:659)
	at org.apache.maven.model.validation.DefaultModelValidator.validateEffectiveDependencies(DefaultModelValidator.java:583)
	at org.apache.maven.model.validation.DefaultModelValidator.validateEffectiveModel(DefaultModelValidator.java:368)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:494)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:440)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:430)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:292)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:255)
	at clojure.tools.deps.alpha.extensions.maven$eval813$fn__815.invoke(maven.clj:99)
	at clojure.lang.MultiFn.invoke(MultiFn.java:244)
	at clojure.tools.deps.alpha$expand_deps$fn__1230$fn__1231.invoke(alpha.clj:214)
	at clojure.tools.deps.alpha.util.concurrent$submit_task$task__500.invoke(concurrent.clj:33)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
error: Recipe `test` failed on line 17 with exit code 1
using cimg/clojure:1.10.1 as image, with Clojure cli version 1.10.1.536

βž• 1
viesti 2020-09-28T08:50:08.068600Z

might be totally relared to this project only, but just thinking out loud, that might there be a concurrency issue in downloading dependencies

alexmiller 2020-09-28T13:09:31.069400Z

You could try adding -Sthreads 1 and see if that helps

viesti 2020-10-02T08:09:12.183800Z

thanks! πŸ™‚

2020-09-28T15:58:09.071100Z

I just updated my clj tools to the latest version and am now getting

CompilerException java.lang.RuntimeException: Unable to resolve symbol: requiring-resolve in this context, compiling:(cljfx/context.clj:37:32) 
which would seem to imply that an older version of clojure being used? Is there an obvious reason this would happen after the clj update? (Both cljfx and my project seem to explicitly depend on clojure 1.10.1)

borkdude 2020-09-28T16:04:56.071400Z

@jjttjj clojure -Stree is your friend here

borkdude 2020-09-28T16:05:08.071900Z

(or whatever is the way of doing the tree now)

2020-09-28T16:10:40.074100Z

Hmmm it looks like clj is giving me a clojure 1.9 repl even though my project only has 1.10 in the tree. might be a scoop issue going to try reinstalling clj Edit: ok I think this is a scoop issue

πŸ‘€ 1
nate 2020-09-28T16:37:57.078Z

a couple of things I've noticed that are different about the new cli tools: - Only the first -M is taken. I used to be able to do -A:one -A:two before and both :one and :two were used (was useful for a script I had that wrapped a call to clojure and I could add extra args if I wanted) - If I put -Spath at the end of my command, it's ignored if there's a -M.... Specifically clojure -Spath -M:repl prints a classpath, but clojure -M:repl -Spath runs the main specified in the :repl alias

alexmiller 2020-09-28T16:49:15.078500Z

Still that for now

borkdude 2020-09-28T16:50:25.080200Z

@nate -M:one:two

alexmiller 2020-09-28T16:50:39.080700Z

-A and -M have always supported multiple aliases so -M:one:two is what you need there. -M and -X should now be last as they grab all args afterwards

alexmiller 2020-09-28T16:51:18.081800Z

So clojure -Spath -M:repl

nate 2020-09-28T16:52:05.082300Z

right, I know that you can put them together, my point is that you used to be able to supply them separately

alexmiller 2020-09-28T16:52:41.083200Z

Now you can’t

nate 2020-09-28T16:52:44.083300Z

I definitely understand why the behavior changed

nate 2020-09-28T16:52:46.083600Z

cool

alexmiller 2020-09-28T16:53:00.084200Z

Multiple -A should still work

nate 2020-09-28T16:53:49.085100Z

interesting point about -A

nate 2020-09-28T16:54:03.085800Z

deprecation warning is pushing me away from that, for good reasons

borkdude 2020-09-28T16:54:36.087100Z

clojure -A:foo -M:bar should also work I think? brings in deps/paths from foo and bar but executes main from bar?

alexmiller 2020-09-28T16:54:44.087600Z

yes

seancorfield 2020-09-28T16:55:26.088600Z

There are a lot more changes in this version than I think are perhaps obvious on the surface -- it's probably always been "best practice" to specify :main-opts separately via a single -M option after using one or more -A options to accumulate aliases but that's never really been codified/written down. This new release sort of "enforces" (or at least "strongly encourages") what I think the core team have always considered best practice...

nate 2020-09-28T16:56:21.089500Z

yeah, I agree with that

seancorfield 2020-09-28T16:56:53.090100Z

-M used to only bring in :main-opts but now brings in paths/deps as well which should not cause any surprises -- but it is quite an important difference.

borkdude 2020-09-28T16:57:15.090500Z

are you referring to a previous pre-release or release?

seancorfield 2020-09-28T16:58:04.091Z

I'm talking about this in the context of "previous stable" and "current stable" releases.

nate 2020-09-28T16:58:15.091600Z

me too

borkdude 2020-09-28T16:58:22.091900Z

I didn't even know there was an -M in a previous release

borkdude 2020-09-28T16:59:07.092200Z

A minor thing but -M -m still feels weird to me :)

alexmiller 2020-09-28T17:00:10.092400Z

consider it encouragement to use -X :)

πŸ‘ 1
borkdude 2020-09-28T17:03:52.094100Z

-X is ok but I don't consider it a substitute for a command line interface for general usage

borkdude 2020-09-28T17:04:07.094400Z

i.e. there will still be a place for tools.cli based tools

borkdude 2020-09-28T17:04:23.094600Z

unless I'm missing something

borkdude 2020-09-28T17:11:49.098200Z

But I guess the -m gets hidden in an alias mostly anyway :)

tvaughan 2020-09-28T17:12:25.099Z

I was doing something like clojure -A:alias-with-main-opts -m some.other.main With the new release I get a deprecation warning to switch to -M, but with -M -m some.other.main are passed as command-line options to the main entry point associated with alias-with-main-opts. Does this mean there's now no way to override a main entry point?

seancorfield 2020-09-28T17:13:32.099500Z

@tvaughan I believe clojure -A:alias-with-main-opts -M -m some.other.main would be the equivalent now.

seancorfield 2020-09-28T17:14:42.099800Z

(I haven't tried that...)

tvaughan 2020-09-28T17:18:17.102200Z

Thanks @seancorfield. Interestingly, this clojure -A:toolbox:dxf-tools -M -m server.core results in an error message from my application about -m not -M being an unknown option. The main-opts associated with dxf-tools are still being used

seancorfield 2020-09-28T17:19:45.103Z

Hmm, sorry. Guess I'll have to do some digging (unless @alexmiller can give a quick answer off the top of his head).

tvaughan 2020-09-28T17:20:55.104Z

No worries. I appreciate the help. I can dig further too. I took a quick look at the changelog but didn't see anything about this specifically

seancorfield 2020-09-28T17:23:10.105Z

Ah, I think this is one of those cases where the advice is to split up :alias-with-main-opts into two aliases -- one with :main-opts (and any deps needed solely for that) and one with all the (other) deps.

seancorfield 2020-09-28T17:24:30.105600Z

(the other option is to continue using the -R and/or -C options even though they are deprecated)

tvaughan 2020-09-28T17:26:19.106200Z

Cool. Thanks. I thought that might be the case. Didn't want to change things without confirmation tho :)

alexmiller 2020-09-28T17:46:20.106900Z

if you're including an uberjar in your classpath, then you've broken the ability of tools.deps to properly resolve libs

alexmiller 2020-09-28T17:46:44.107300Z

b/c it can't "see" inside the uberjar to tell what libs are included there or their versions

2020-09-28T17:52:30.108100Z

That makes sense

seancorfield 2020-09-28T18:15:00.109500Z

@alexmiller Now that 1.10.1.697 is the stable release, there are four mentions of clj -m <some.ns> in https://clojure.org/guides/deps_and_cli that need to be updated to include -M if you want folks to avoid the clojure.main warnings (i.e., "WARNING: When invoking clojure.main, use -M").

seancorfield 2020-09-28T18:15:17.109900Z

Those all need to be clj -M -m <some.ns> now, right?

seancorfield 2020-09-28T18:23:50.111500Z

(also, I added a note on TDEPS-100 that indicates some confusion over -A since the reference page does not define clj-opt and clojure -h says that -A is an exec-opt which seems to be at odds with the CLI/deps reference text)

borkdude 2020-09-28T19:21:20.112700Z

yes, now I feel the issue we discussed last weekend. I have this:

{;;:paths ["your-packages"]
 ;;:deps {your-org/your-packages {,,,}}
 :aliases
 {:glam {:extra-deps
         {borkdude/glam {:git/url "<https://github.com/borkdude/glam>"
                         :sha "4599fb019deae9418d76a9996ae19b4003f3cc96"}}
         :main-opts ["-m" "glam.main"]}}}
and now I want to do:
bb -cp $(clojure -R:glam -Spath) -m glam.main --install clj-kondo/clj-kondo --global --verbose
but I have to make two aliases now, so from Clojure this becomes:
clojure -M:glam-deps:glam
:/

borkdude 2020-09-28T19:22:23.113100Z

with -Spath it's pretty clear you don't want to run the main right

borkdude 2020-09-28T19:22:54.113600Z

so why not ignore the main when doing this:

clojure -A:glam -Spath

borkdude 2020-09-28T19:23:36.113900Z

that doesn't seem to be breaking

borkdude 2020-09-28T19:33:04.114300Z

ah well, bash to the rescue:

{:aliases
 {:glam/packages {:extra-deps
                  {borkdude/glam {:git/url "<https://github.com/borkdude/glam>"
                                  :sha "4599fb019deae9418d76a9996ae19b4003f3cc96"}
                   ;; your-org/your-packages {,,,}
                   }
                  ;; :extra-paths ["your-packages"]
                  }
  :glam {:main-opts ["-m" "glam.main"]}}}
alias glam='clojure -M:glam/packages:glam'
$ glam --install clj-kondo/clj-kondo org.babashka/babashka

alexmiller 2020-09-28T20:02:14.115200Z

Yeah it’s on my list to update this week

1
seancorfield 2020-09-28T20:03:45.115800Z

@borkdude If you put -Spath first it will not run the main.

borkdude 2020-09-28T20:04:13.116Z

ah really

borkdude 2020-09-28T20:04:24.116300Z

thanks!

seancorfield 2020-09-28T20:05:08.117200Z

And that's supposed to be clear from the docs which show clj [clj-opt*] [exec-opt] as the syntax -- -Spath is a clj-opt, -M is an exec-opt

borkdude 2020-09-28T20:05:32.118Z

yep, makes sense, thanks for clearing that up

seancorfield 2020-09-28T20:05:59.118400Z

(as I just noted to @alexmiller it's not clear whether -A is meant to be a clj-opt or an exec-opt at this point, esp. given that at some future date it will stop running :main-opts)

alexmiller 2020-09-28T20:06:24.118900Z

It’s kind of in a gray area

alexmiller 2020-09-28T20:06:44.119300Z

But I think I would call it a clj-opt

seancorfield 2020-09-28T20:10:26.120100Z

At this point, I'm hoping that -A stops running :main-opts fairly soon and it can be clearly classified as a clj-opt and then -R and -C can be fully removed.

borkdude 2020-09-28T20:33:00.120400Z

@seancorfield I'm still getting the warning:

$ clojure -Sforce -Spath -A:glam
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.

borkdude 2020-09-28T20:33:32.120600Z

I don't want main, I want path

borkdude 2020-09-28T20:33:43.120800Z

I used to use -R -C for this

borkdude 2020-09-28T20:34:19.121400Z

can I rely on this being a correct invocation and the warning begone next version?

seancorfield 2020-09-28T20:34:29.121600Z

clojure -Sforce -Spath -M:glam should work.

seancorfield 2020-09-28T20:34:41.122Z

-Spath implies -P I believe.

borkdude 2020-09-28T20:34:43.122100Z

it works, but I get the warning

seancorfield 2020-09-28T20:35:13.122300Z

(! 696)-&gt; clojure -Sforce -Spath -M:runner
src:resources:/Users/sean/.gitlibs/libs/com.cognitect/test-runner/f7ef16dc3b8332b0d77bc0274578ad5270fbfedd/src:/Users/sean/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/Users/sean/.m2/repository/org/clojure/tools.cli/0.3.5/tools.cli-0.3.5.jar:/Users/sean/.m2/repository/org/clojure/tools.namespace/0.2.11/tools.namespace-0.2.11.jar:/Users/sean/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:/Users/sean/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar

seancorfield 2020-09-28T20:35:50.122900Z

Without -Spath that runs the tests (or attempts to -- it's missing the :test alias)

borkdude 2020-09-28T20:36:01.123200Z

aha, with -M it doesn't warn, but with -A it does... that's weird

borkdude 2020-09-28T20:36:28.123600Z

I think -A is the preferred way for creating paths right

seancorfield 2020-09-28T20:36:39.123800Z

(! 698)-&gt; clojure -Sforce -M:test:runner

Running tests in #{"test"}

Testing tvaughan.example-test

FAIL in (a-test) (example_test.clj:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.
(! 699)-&gt; clojure -Sforce -Spath -M:test:runner
test:src:resources:/Users/sean/.gitlibs/libs/com.cognitect/test-runner/f7ef16dc3b8332b0d77bc0274578ad5270fbfedd/src:/Users/sean/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/Users/sean/.m2/repository/org/clojure/test.check/1.0.0/test.check-1.0.0.jar:/Users/sean/.m2/repository/org/clojure/tools.cli/0.3.5/tools.cli-0.3.5.jar:/Users/sean/.m2/repository/org/clojure/tools.namespace/0.2.11/tools.namespace-0.2.11.jar:/Users/sean/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:/Users/sean/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar
(! 700)-&gt; 
πŸ™‚

borkdude 2020-09-28T20:37:14.124200Z

anyway, I'll be using -A (and advocating it in my README) and expect the warning to be gone some time in the future

borkdude 2020-09-28T20:40:01.124500Z

clojure -Sforce -Spath -A:glam 2&gt;/dev/null

borkdude 2020-09-28T20:42:23.125Z

Feel free to comment on this README for improved clojure usage in case I missed something: https://github.com/borkdude/glam