tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
borkdude 2021-02-14T10:32:10.279100Z

3
alexmiller 2021-02-14T14:01:39.279300Z

wizardry

coby 2021-02-14T20:30:44.282500Z

I'm a little fuzzy on the distinction between clj's -A and -M options. What exactly is a "main option" alias and how does it differ from normal aliases/"aliases of any kind"? (Side note: where did that diagram go with all the arrows labeled with the different CLI options? Could've sworn it was on the deps/cli reference page or the guide)

borkdude 2021-02-14T20:34:12.283800Z

@ctamayo -A is for invoking a REPL, -M is for invoking clojure.main (typically with a -main function with :main-args), -X is for executing a function, typically with pre-configured args in deps.edn.

alexmiller 2021-02-14T20:40:03.284100Z

the diagram was removed as it was mostly no longer correct

1
coby 2021-02-14T20:43:32.286300Z

so -M:some-alias -m my.project a b c is like calling (my.project/-main a b c) right? And :some-alias presumably just adds extra stuff to the classpath that the my.project ns needs?

borkdude 2021-02-14T20:44:49.286500Z

correct

coby 2021-02-14T20:54:42.291700Z

Thanks! OK so I think something weird is happening. This has happened once or twice before - I forget where - but most recently on the datahike test suite: Commands that are documented with -M fail with a FileNotFoundException, but succeed when I use -A instead. So for example running unit tests exactly as they are invoked by the helper scripts (https://github.com/replikativ/datahike/blob/development/bin/kaocha via https://github.com/replikativ/datahike/blob/development/bin/run-unittests) gives me:

$ TIMBRE_LEVEL=':fatal' clojure -M:test -m kaocha.runner --focus :clj
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate kaocha/runner__init.class, kaocha/runner.clj or kaocha/runner.cljc on classpath.
Full report at:
/tmp/clojure-16371792498407115921.edn
But switching to -A:test works.

seancorfield 2021-02-14T20:55:51.292300Z

@ctamayo That indicates the version of clojure is too old.

seancorfield 2021-02-14T20:56:34.293Z

clojure -Sdescribe will tell you what version it is. You need at least 1.10.1.697 per https://clojure.org/releases/tools

coby 2021-02-14T20:57:07.294Z

ah, I was looking for a --version option or something. Good to know, thank you!

seancorfield 2021-02-14T20:57:18.294300Z

In older versions of clojure the -M option did not respect :extra-deps so part of the alias would not be pulled in (the dependencies), just the :main-opts part.

seancorfield 2021-02-14T20:58:01.294800Z

clojure -h displays the version (at the top of the help) as well as clojure -Sdescribe

1
coby 2021-02-14T20:59:42.296Z

not sure how I missed that at the top of clojure -h! Guess I need a break. 🧟

seancorfield 2021-02-14T21:03:01.296600Z

It scrolls off the top of the screen for me so I tend to recommend clojure -Sdescribe because the output is shorter.

coby 2021-02-14T21:06:44.298800Z

I also had an embarrassingly old version (1.10.0.411) that didn't print that at the top. But I will remember that trick! And also take a break still. 😛

seancorfield 2021-02-14T21:09:46.299500Z

Also worth noting that the latest is 1.10.2.774 now that Clojure 1.10.2 is out (not 1.10.1.x).

1
coby 2021-02-14T21:11:57.299900Z

yep, that is the one I just installed and it's working now!

zane 2021-02-14T23:24:28.301400Z

Is there a way to find out which version of Jetty the installed Clojure tools are using?

seancorfield 2021-02-14T23:37:40.302200Z

@zane Jetty? I wouldn't expect the Clojure tools to be using a web server. Can you provide a bit more context?

seancorfield 2021-02-14T23:50:54.303Z

If you mean "in a deps.edn project, where Jetty is a transitive dependency", you can use clojure -Stree