Troubleshooting

Here are solutions to some common problems with Cursive.

Help! Lots of symbols don't resolve!

There are many things that can cause problems like this. Here's a quick checklist of things to try:

  1. If your unresolved symbols all seem to be related to a particular macro, you may be able to help Cursive understand it. See Macro Support for more details.
  2. The next thing to check is that you have a JDK configured for your module. Use Ctrl+Alt+Shift+S (File→Project Structure...), then choose Modules and check your module has a JDK. If your module delegates to the project JDK you can check that is configured correctly in the Project section. This can become misconfigured when you update IntelliJ. This is the most likely culprit in cases where normal symbols resolve correctly but symbols from the JDK via interop do not.
  3. Next, check that your project has been added to the project correctly. Open the Lein/Deps toolwindow and check that you see your project there. If it's not, then right click on the project.clj or deps.edn in the Project toolwindow and choose Add as Lein/Deps project.
  4. Next, check that your project has its dependencies synchronised correctly. Use Ctrl+Alt+Shift+S (File→Project Structure...), then choose Modules and select the module you're having problems with. Then choose the Dependencies tab and check that the dependencies you're expecting appear there. If not, then check your notifications to see if Cursive is reporting any problems synchronising the dependencies for your project. Also, you might have to configure your aliases (for deps) or your profiles (for Leiningen).
  5. If all else fails, the next thing to try is File→Invalidate Caches.... Sometimes the indexes can become corrupted and that will fix them.

Unresolved symbols from clojure.core when sending forms to REPL

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 my-ns.core namespace.

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 ns.

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.

Cursive on IntelliJ EAP builds

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.

I can't close my parentheses!

See Structural Editing.


AOT Compilation Getting Help