oakes / Nightlight

An embedded editor for Clojure
https://sekao.net/nightlight/
The Unlicense
788 stars 35 forks source link

Errors "java.lang.Exception: namespace * not found" in InstaREPL #12

Closed kholodilov closed 7 years ago

kholodilov commented 7 years ago

I'm trying to use InstaREPL and get errors like: java.lang.Exception: namespace 'clojure.tools.analyzer.passes.constant-lifter' not found, compiling:(clojure/tools/analyzer/passes/jvm/constant_lifter.clj:1:1) This is my project: https://github.com/kholodilov/core-async-playground/ Also, I cannot access code from my project in REPL, getting "CompilerException java.lang.RuntimeException: No such var" errors - probably, related thing.

oakes commented 7 years ago

Are you using the lein plugin? It seems to have this issue.

oakes commented 7 years ago

@kumarshantanu do you know if the lein plugin is running in the same process as the project? perhaps we need to modify it so the REPL and instaREPL work as expected.

oakes commented 7 years ago

@kholodilov in the meantime, you can avoid using the plugin and just run the start function directly inside your project. see the website for details on how to do this.

kumarshantanu commented 7 years ago

I am unable to reproduce the errors @kholodilov mentioned (I may be using a different workflow), but I guess attempting to run the plugin in a separate process is worth trying. To run the plugin in a separate process, just set :eval-in-leiningen false in lein-nightlight/project.clj in the Nightlight repo and build locally using the lein do clean, install command.

oakes commented 7 years ago

I think running in the same process would be ideal. However, with lein nightlight I don't seem to have access to the project's namespaces. In a blank app created via lein new app ... if I run lein nightlight the REPL doesn't seem to have access to the namespaces or dependencies of the project. I don't know enough about lein plugins, though, so I may need to investigate further.

kumarshantanu commented 7 years ago

@oakes After I set :eval-in-leiningen false (with a local build) the project sources seem to be available in the REPL for me. I tested this with the repo @kholodilov cited.

kumarshantanu commented 7 years ago

I got InstaREPL working too for the said repo with the :eval-in-leiningen false setting. Looks like this could be the fix. @oakes Happy to send a PR if it fixes the issue, though it's a trivial change.

oakes commented 7 years ago

Hmm I tried a local build that has :eval-in-leiningen false and re-ran it in a blank project and it seems to still have trouble. I normally test it by doing (in-ns 'hello-world.core) and then try to run (-main). Am I doing something wrong? It seems to still not recognize it for me.

kumarshantanu commented 7 years ago

I usually do (require '[project-ns.core :as c]) followed by (c/-main) or equivalent. @oakes Could you try that once?

oakes commented 7 years ago

Confusingly enough, that seems to work even with :eval-in-leiningen true :D Perhaps the namespaces aren't being eval'ed until require is called? It's hard to think of another reason why in-ns wouldn't work...

kumarshantanu commented 7 years ago

Hmm, looks like things (REPL and InstaREPL) are working fine if you do a require in the REPL first, regardless of the :eval-in-leiningen setting. :-/

oakes commented 7 years ago

Finally fixed the issue in 1.3.1. Not sure why I didn't think of this, but all I did was a require on the main namespace in the eval-in-project call: 3e4e0fd04181c412354c08243ae4a029dd165ae3