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