Here are solutions to some common problems with Cursive.
If you’re seeing errors like the following when sending forms from your editor to the REPL:
CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(....scratch.clj:17:3)
it can be very confusing since it seems like vars from
clojure.core should always be available. Additionally, entering the form in the REPL editor works fine.
Here’s how this works. When sending forms to the REPL, there are two options, controlled by a config flag: Settings→Languages & Frameworks→Clojure→Evaluate forms in REPL namespace. This controls whether the forms will be executed in the current REPL namespace, or in the namespace of the file from which they were sent. So for example, if you send a form from a file which defines
my-ns.core and your REPL is currently in
user, that form will by default be executed in the
This issue is due to the way Clojure creates its namespaces. If you macro expand an
ns form (which I recommend you do sometime, it’s interesting to see how it works), you’ll see that it calls
in-ns which creates the namespace if it doesn’t exist. It then refers
clojure.core into it, which is what gives you bare access to everything from core. However when a form is executed in the context of a namespace, it just calls
in-ns but does not do the refer step. This means that if the namespace has not been loaded previously, you get what is technically a namespace, but one that has not been initialised as you would expect if you used
The solution is to ensure that your namespace is correctly loaded before trying to load forms from it. You can do this either by loading the entire file, or just sending the
ns form to the REPL.
If you want to use Cursive with an EAP build of IntelliJ from an upcoming version, you may discover that it’s not visible in the plugin repository. The problem is that new IntelliJ EAP builds are often only supported by the latest Cursive EAP, and by default EAPs are not enabled. But it’s a Catch-22, because you need Cursive installed to say you want EAP builds. However you can do this manually - open Settings→Plugins→Browse Repositories→Manage Repositories, and add a repository with the address: https://plugins.jetbrains.com/plugins/eap/8090. Then go back to Browse Repositories, refresh and you should see the plugin then.
See Structural Editing.