Fork me on GitHub
#cider
<
2023-02-22
>
winsome20:02:05

I'd like to run eval a form in a new repl right after it has started, is there a way to configure cider-jack-in to do that? Specifically (set! *print-namespace-maps* false).

vemv20:02:36

leveraging user.clj might suffice Sometimes alter-var-root is more effective for these (even if altering clojure.core is yucky), dyn vars are funny, especially when considering a complex thing like nREPL

winsome20:02:19

user.clj gave me some guff. Using (set! *print-namespace-maps* false) blows it up:

error in process sentinel: Could not start nREPL server: Exception in thread "main" Syntax error macroexpanding at (user.clj:37:1).
	at clojure.lang.Compiler.load(Compiler.java:7665)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:368)
	at clojure.lang.RT.maybeLoadResourceScript(RT.java:364)
	at clojure.lang.RT.doInit(RT.java:486)
	at clojure.lang.RT.init(RT.java:467)
	at clojure.main.main(main.java:38)
Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *print-namespace-maps* with set
	at clojure.lang.Var.set(Var.java:226)
	at user$eval73697.invokeStatic(user.clj:38)
	at user$eval73697.invoke(user.clj:38)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	... 6 more
And using (alter-var-root #'*print-namespace-maps* (constantly false)) didn't appear to work - it's still set to true. In any case, I'd like to not force my preference on my coworkers if possible.

enn20:02:03

Not sure if there’s a way to do this on the CIDER side. I solved the same problem using :main-opts in my ~/.clojure/deps.edn:

{
 :aliases {:cider {:main-opts  ["-e" "(set! *print-length* 50)"
                                "-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}
 }
I don’t use cider-jack-in (I start Clojure separately and then cider-connect) but I think you can configure options to pass with the cider-clojure-cli-global-options customization (assuming you use the Clojure CLI).

vemv20:02:40

> it's still set to true. yeah there's a chance that cider or nrepl perform a binding internally, which one cannot override from the outside Do feel free to create an issue for the print-namespace-maps problem - I've felt it too at times