Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure CLI by

I tried to find guidance from clojure --help and reading through the docs at clojure.org, but I couldn't find any CLI option flag that could "fail fast" if -M:undeclared-alias is not found?

Currently (with at least) you will only get a warning printed followed by the REPL prompt:
❯ clojure -M:not-found WARNING: Specified aliases are undeclared and are not being used: [:not-found] Clojure 1.11.1 user=> ^D ❯ clojure -version Clojure CLI version

I would like to see, at least in clojure tool an option that instead of printing a warning and continuing normally, it would exit with code > 0, if you try to invoke with undeclared alias. Then for example CI builds could fail fast in case of typos/misconfigurations.

Something like --strict-aliases?

Bumped into this unfortunate behavior today in our CI build, where the CI script had cd'd to a wrong directory, and tried to start our alias defined in deps.edn, which would've contained {:main-opts ["--main" "our-test.runner"]}.

So CI was doing this clojure -M:our-tests in wrong directory which had no deps.edn file. Result was that only REPL prompt appeared - and after that for some reason, unrelated to this, the build job exited with exit 0 and the pipeline was green.
Just happened to notice this randomly, that it was not actually running the tests. Oops.

I could of course do some checks in CI script around the clojure call, but I feel like this could be a beneficial feature of the CLI.

1 Answer

+2 votes
selected by
Best answer

I logged as https://clojure.atlassian.net/browse/TDEPS-230. Not sure I actually want to do this but I can sit on the idea for a while.