Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using do in lein :repl-options leads to error #124

Open
kovasap opened this issue May 14, 2022 · 0 comments
Open

Using do in lein :repl-options leads to error #124

kovasap opened this issue May 14, 2022 · 0 comments

Comments

@kovasap
Copy link

kovasap commented May 14, 2022

Based on the README (https://github.com/nrepl/piggieback#usage), it seems like I need to execute lein repl, then:

(require 'cljs.repl.node)
(cider.piggieback/cljs-repl (cljs.repl.node/repl-env))

in order to get a cljs repl I can interact with.

I attempted to do this by adding this to my project.clj:

  :repl-options {:init (do (require 'cljs.repl.node)
                           (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
                 :nrepl-middleware [cider.piggieback/wrap-cljs-repl]}

However, when I do this, I get:

> lein repl
Exception in thread "main" java.lang.IllegalStateException: Can't change/establish root binding of: *cljs-repl-env* with set, compiling:(/tmp/form-init6720131333940924525.clj:1:73)
	at clojure.lang.Compiler.load(Compiler.java:7526)
	at clojure.lang.Compiler.loadFile(Compiler.java:7452)
	at clojure.main$load_script.invokeStatic(main.clj:278)
	at clojure.main$init_opt.invokeStatic(main.clj:280)
	at clojure.main$init_opt.invoke(main.clj:280)
	at clojure.main$initialize.invokeStatic(main.clj:311)
	at clojure.main$null_opt.invokeStatic(main.clj:345)
	at clojure.main$null_opt.invoke(main.clj:342)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalStateException: Can't change/establish root binding of: *cljs-repl-env* with set
	at clojure.lang.Var.set(Var.java:223)
	at cider.piggieback$cljs_repl.invokeStatic(piggieback_impl.clj:184)
	at cider.piggieback$cljs_repl.doInvoke(piggieback_impl.clj:146)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at user$eval1711.invokeStatic(form-init6720131333940924525.clj:1)
	at user$eval1711.invoke(form-init6720131333940924525.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7062)
	at clojure.lang.Compiler.eval(Compiler.java:7052)
	at clojure.lang.Compiler.eval(Compiler.java:7052)
	at clojure.lang.Compiler.eval(Compiler.java:7051)
	at clojure.lang.Compiler.load(Compiler.java:7514)
	... 12 more

So I've been using a shell script instead to start my repl:

#!/bin/zsh

(echo "(require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env))"; cat <&0) | lein repl

This seems weird to me - is this intended behavior or am I missing the proper way to set this up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant