Clj: Implicit use of clojure.main with options is deprecated

Hello all,
I think I am getting lost in a glass of water. I used to run Clojure on the shell by using

clj -m module

Where said module has a -mainfunction. And it works. See eg cli-matic/toycalc.clj at master · l3nz/cli-matic · GitHub

But now I get a warning:

WARNING: Implicit use of clojure.main with options is deprecated, use -M

And I’m not finding the correct incantation to run the same command as before but without the warning printed.

clj -M -m module

The -M flag means "use clojure.main" and then -m module is consumed by clojure.main, where -m means “run -main in this namespace”.

The -A flag currently still runs clojure.main but will stop doing that at some point and will just start a REPL.

The -X flag means “execute this function”.

See Clojure - Deps and CLI Guide for more details.

Thanks - I did look there but did not really understand how it was. Some days the brains just won’t connect. :grinning:

I wrote an article on Clojure CLI execution options, -A -M -P -T -X, with examples, to help remember the for of each and when to use them
https://practical.li/blog/posts/clojure-which-execution-option-to-use/

3 Likes