Fork me on GitHub
#tools-deps
<
2021-02-14
>
coby20:02:44

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)

borkdude20:02:12

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

Alex Miller (Clojure team)20:02:03

the diagram was removed as it was mostly no longer correct

3
coby20:02:32

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?

coby20:02:42

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.

seancorfield20:02:51

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

seancorfield20:02:34

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

coby20:02:07

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

seancorfield20:02:18

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.

seancorfield20:02:01

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

3
coby20:02:42

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

seancorfield21:02:01

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

coby21:02:44

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

seancorfield21:02:46

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

3
coby21:02:57

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

zane23:02:28

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

seancorfield23:02:40

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

seancorfield23:02:54

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