Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get Cider working

Last month someone helped me get Cider working on a Clojure project. I loved the functionality, particularly M-., cider-jump-to-var. But since then I haven't been able to replicate the correct behavior, either in the original project or in a new one, and the person who helped set me up originally is no longer available.

In the original project, which I still have checked out, there's a line

[cider/cider-nrepl "0.7.0"]

in the :dependencies section of my project.clj. When I add such a line to my new project, then run lein repl and cider-connect, I get this message:

; CIDER 0.8.0alpha (package: 20141006.507) (Java nil, Clojure 1.6.0, nREPL 0.2.3)
WARNING: The following required nREPL ops are not supported: 
classpath complete info inspect-start inspect-refresh inspect-pop inspect-push inspect-reset macroexpand ns-list ns-vars resource stacktrace toggle-trace undef
Please, install (or update) cider-nrepl 0.8.0-snapshot and restart CIDER
WARNING: CIDER's version (0.8.0-snapshot) does not match cider-nrepl's version (0.7.0)

Sure enough, when I to jump to the definition of a symbol (say first), I get:

cider-ensure-op-supported: Can't find nREPL middleware providing op "info".  Please, install (or update) cider-nrepl 0.8.0-snapshot and restart CIDER

Oddly, I get the same error when I change the version of cider/cider-nrepl to "0.8.0-SNAPSHOT" in project.clj.

But then I notice on the cider-nrepl Github page that the cider/cider-nrepl line is supposed to be in :plugins, not :dependencies. It definitely wasn't in my original project, but it still worked somehow. Fine, so I move it to :plugins in my new project. This time the nrepl process starts up with no errors, but when I try to jump to the definition of, again, say, first, I get:

Symbol first not resolved

Now if I try downgrading back to 0.7.0, I get a shorter message when I start up cider:

WARNING: The following required nREPL ops are not supported: 
ns-list ns-vars undef
Please, install (or update) cider-nrepl 0.8.0-snapshot and restart CIDER
WARNING: CIDER's version (0.8.0-snapshot) does not match cider-nrepl's version (0.7.0)

...but I get the same "Symbol first not resolved" as before.

This is really frustrating. I vaguely recall some kind of version mismatch message when I worked on my original project, and the jump-to-definition feature still worked. Now I can't get it working for the life of me. Any assistance would be immensely appreciated.

EDITED TO ADD:

Before embarking on the exploration described above, I deleted and re-installed Cider from my packages list. I also deleted ~/.m2/repository/cider between each step.

This morning, I had Cider version 20141006.507. An update was available, so that I now have version 20141007.452. The command cider-version returns just CIDER 0.8.0-snapshot. With [cider/cider-nrepl "0.8.0-SNAPSHOT"] in the :plugins section of my project.clj, I still get Symbol <whatever> not resolved no matter which symbol I try.

like image 880
Sean Avatar asked Oct 07 '14 08:10

Sean


2 Answers

You are most likely installing the CIDER package in Emacs from the MELPA repository which means you are installing the latest CIDER snapshot package which requires the [cider/cider-nrepl "0.8.0-SNAPSHOT"] middleware in your project.clj to function correctly.

Since you are using the CIDER snapshot package you can also not use the 0.7.0 CIDER middleware.

When you launch a repl using M-x cider-jack-in or from the command line using lein repl, the latest CIDER middleware is checked for and downloaded (by default, daily) by Leiningen prior to launching the repl.

This means that your middleware snapshot may become out of sync with your Emacs CIDER package version since by default you will have the Emacs CIDER package snapshot that was installed at the time you manually installed it.

In order to bring the middleware and Emacs CIDER package back into sync you should install the latest CIDER Emacs package via M-x package-list-packages and select the cider package for installation.

You should then restart Emacs and run M-x cider-version and confirm that you get the following (as of today) in Messages:

CIDER 0.8.0snapshot (package: 20141007.13)

cider-jump-to-var and all other CIDER functionality should then work.

like image 113
Symfrog Avatar answered Oct 20 '22 14:10

Symfrog


So apparently the main bit I was missing, which I stumbled upon accidentally, was that before M-. will work, I needed to go up and evaluate the file's initial ns form with C-xC-e (cider-eval-last-sexp).

Occasionally I'll get some unhelpful error message when trying to jump to a definition, like "Wrong type argument: arrayp", but it works often enough to be usable.

Suggestions for how to improve this process would be welcome.

like image 41
Sean Avatar answered Oct 20 '22 15:10

Sean