Is it possible to use middleware `io.aviso/pretty` with Clojure CLI (deps.edn)?

No, nothing like this. clj just runs clojure.main, which is just a program runner, so there are a variety of ways to have it run programs around your repl (which is of course, also just a program) if you like.

For example, you could create a script that injects pretty, then starts the repl:

$ cat myrepl.clj
((requiring-resolve 'io.aviso.repl/install-pretty-exceptions))
(clojure.main/main)

Then create a deps.edn with an alias that includes pretty and runs the script (this and the prior file could also be in your ~/.clojure dir, becoming available to all deps.edn projects):

$ cat deps.edn
{:aliases
 {:myrepl {:extra-deps {io.aviso/pretty {:mvn/version "0.1.37"}}
           :main-opts ["myrepl.clj"]}}}

Then start clj with your alias:

$ clj -A:myrepl
Clojure 1.10.0
user=> (/ 1 0)
java.lang.ArithmeticException: Divide by zero
user=> (pst)
clojure.core/eval    core.clj: 3214
              ...
     user/eval744  myrepl.clj:    1
              ...
java.lang.ArithmeticException: Divide by zero

There are of course an infinite number of ways to install/configure/start/prep your repl but you have full program-making capability at your fingertips.

3 Likes