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

Error when trying out shimdandy in repl #8

Closed
zcaudate opened this Issue Apr 8, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@zcaudate
Copy link

zcaudate commented Apr 8, 2019

When shimdandy is called within a repl environment, this exception occurs and the repl freezes. Is there a way around this?

(ClojureRuntimeShim/newRuntimeExecution error (IllegalStateException) at nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:79).
Pop without matching push
Execution error (IllegalStateException) at nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:79).
Can't change/establish root binding of: *e with set
Exception in thread "nRepl-session-ac95791c-9ff2-4a62-b44d-4164ad60b8c3" java.lang.IllegalStateException: Pop without matching push
	at clojure.lang.Var.popThreadBindings(Var.java:336)
	at clojure.core$pop_thread_bindings.invokeStatic(core.clj:1931)
	at clojure.core$pop_thread_bindings.invoke(core.clj:1931)
	at nrepl.middleware.interruptible_eval$interruptible_eval$fn__921$fn__925.invoke(interruptible_eval.clj:141)
	at clojure.lang.AFn.run(AFn.java:22)
	at nrepl.middleware.session$session_exec$main_loop__1022$fn__1026.invoke(session.clj:171)
	at nrepl.middleware.session$session_exec$main_loop__1022.invoke(session.clj:170)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:834)
@tobias

This comment has been minimized.

Copy link
Member

tobias commented Apr 8, 2019

How is this project structured? Are you loading Shimdandy from Clojure or Java? Is clojure.jar on the top-level classpath? If clojure.jar is on the classpath, you can't use Shimdandy (see https://github.com/projectodd/shimdandy#usage). If it isn't, would you mind providing a project or instructions that reproduces the error?

@zcaudate

This comment has been minimized.

Copy link
Author

zcaudate commented Apr 8, 2019

I think that’s the problem. It’s just a normal leiningen project. clojure is being loaded first.

When using the boot repl, the error occurs on runtime instantiation but works fine afterwards. How would you recommend calling the shim via a repl?

@tobias

This comment has been minimized.

Copy link
Member

tobias commented Apr 8, 2019

I don't know how to work around the issue of being able to call it from the repl, and even if we were able to, I'm not sure of the value - if clojure.lang.RT.class is visible to the classloader given to the shim, then Shimdandy isn't giving you any isolation - every shim will share the same Clojure runtime.

However, you may be able to:

  1. Start a shim from a java process that doesn't have clojure.jar on the classpath
  2. Hold a reference to the classloader that loaded your Java code (the one you used to start the shim)
  3. Start a repl inside that shim by calling nrepl, etc
  4. Use the classloader from step 2 to start more shims within the repl

Note that you may see odd equality issues if you tried to use any return values from the shims within the repl (for example, :foo from shim A would not equal :foo from shim B).

@zcaudate

This comment has been minimized.

Copy link
Author

zcaudate commented Apr 8, 2019

yep. that makes sense. I’ll give that a go. Another way might be to use the base app classloader.

@zcaudate

This comment has been minimized.

Copy link
Author

zcaudate commented Apr 8, 2019

using the base class loader is a bad idea. thanks for the tip.

@zcaudate zcaudate closed this Apr 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.