tools-deps

grzm 2023-06-16T20:26:00.607609Z

Should --report stderr work with an alias that includes :main-opts? For example, I'd expect this to echo to stderr rather than writing to a file:

% clj -e "(-> (slurp \"deps.edn\") ((requiring-resolve 'clojure.edn/read-string)) (get-in [:aliases :main]))"
{:main-opts ["-m" "my.main"], :jvm-opts ["-Dclojure.spec.check-asserts=true" "-Djdk.internal.httpclient.disableHostnameVerification=true"]}
% clj -M:main --report=stderr
Execution error [redacted]

Full report at:
/var/folders/p0/qtwr_lhx6dlf8kddzgrbsn180000gp/T/clojure-11739203642877558907.edn

grzm 2023-06-16T20:27:41.022779Z

Passing the clojure.main.report Java property does what I expect:

% clj -J-Dclojure.main.report=stderr -M:main
Caught error [reacted]
{:clojure.main/message ,,,,

grzm 2023-06-16T20:28:50.383829Z

But --report stderr is so much nicer to type at the command line (if it works)

2023-06-16T20:39:22.480009Z

--report stderr is an option for clojure.main so it would go in main-opts, my guess would be --report stderr is being interpreted here as an argument for your code and being passed to my.main

grzm 2023-06-16T20:43:13.240719Z

Yeah, that's likely what's happening. Just would be nice to be able to toggle it at the command line more easily.

% clj --help
Version: 1.11.1.1347
...
  Run main      clojure [clj-opt*] -M[aliases] [init-opt*] [main-opt] [arg*]
...
init-opt:
 -i, --init path     Load a file or resource
 -e, --eval string   Eval exprs in string; print non-nil values
 --report target     Report uncaught exception to "file" (default), "stderr", or "none"