nrepl/piggieback

Exception when printing in piggieback

weavejester opened this issue · 4 comments

Currently I'm getting the following error

java.lang.IllegalStateException: Can't change/establish root binding of: *cljs-compiler-env* with set
    at clojure.lang.Var.set(Var.java:221)
    at cemerick.piggieback$run_cljs_repl$fn__18501.doInvoke(piggieback.clj:184)

Which despite the stacktrace insisting it's on line 184, the exception appears to be referring to line 191.

Presumably this line is meant to be executed within a binding of *cljs-compiler-env*, since set! will only work on local bindings of vars, but I don't see where in the code that should be set.

This happens only if the wrap-cljs-repl middleware isn't folded into your nREPL stack, or for some reason is not layered in there properly.

"Are you sure it's plugged in?" ;-D

Ohhhh! I completely misunderstood the purpose of the wrap-cljs-repl middleware. I assumed it was for automatically mixing in Piggieback, rather than being supporting middleware. In retrospect I don't see why I thought that.

Thanks for pointing out I wasn't plugged in :)

Hm, actually maybe I was too quick to close this. I've added the middleware as described in the README, but I still get the same exception. I'm going to try poking around a little to see if it's something I've done wrong (again), but I'll leave the issue open until I find something.

I've discovered the reason behind the error I was seeing. It's nothing to do with Piggieback. It's instead caused by Figwheel assuming that the (:print cljs.repl/*repl-opts*) function remains the same, so it sets it once during setup instead of checking it each time.