6

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.

Bozhidar Batsov
  • 55,802
  • 13
  • 100
  • 117
Sean
  • 29,130
  • 4
  • 80
  • 105

2 Answers2

10

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.

Symfrog
  • 3,398
  • 1
  • 17
  • 13
  • 1
    FWIW, I've taken to using the stable melpa package site in order to avoid bleeding-edge issues like this. http://melpa-stable.milkbox.net/packages/ – Roger Allen Oct 07 '14 at 14:53
  • Did you restart Emacs after installing the latest CIDER package? When I invoke M-x cider-version I get "CIDER 0.8.0snapshot (package: 20141007.13)" in the minibuffer. – Symfrog Oct 07 '14 at 15:42
  • 1
    So, you're not getting any warnings now, right? Are you doing `C-c C-k` (compile namespace) in the namespaces you want to work with? – Bozhidar Batsov Oct 07 '14 at 16:15
  • "Every time you launch a repl using M-x cider-jack-in or from the command line using lein repl, the latest CIDER middleware is downloaded by leiningen prior to launching the repl." this is false, the default is to check for snapshot updates once every 24 hours, though it is configurable – noisesmith Oct 07 '14 at 18:56
  • 1
    Also, fixing version mismatch issues by installing the latest development tip of each library is volunteering to be an alpha tester - it's a community service, but it may not be very productive. – noisesmith Oct 07 '14 at 18:59
  • @noisesmith Thanks, changed "Every time" to "daily" – Symfrog Oct 08 '14 at 07:22
1

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.

Sean
  • 29,130
  • 4
  • 80
  • 105
  • The namespace has to be loaded into the environment before you will be able to jump to vars otherwise there would be nothing to jump to. You can set [:main](https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L196) in Leiningen's project.clj to load a namespace automatically when launching a repl with lein. You would still experience the error described if you have mismatched CIDER package/middleware versions, therefore this is not the root cause of the problem that you posted. – Symfrog Jan 03 '15 at 15:00