How to upgrade nrepl version of leiningen?
Asked Answered
F

4

44

I'm using leiningen and emacs + cider for clojure development. A few days ago, after I upgrade cider through emacs package manager, I'm getting the following warning message when I run M-x cider-connect or M-x cider-jack-in.

; CIDER 0.9.0snapshot (package: 20150222.137) (Java 1.8.0_31, Clojure 1.6.0, nREPL 0.2.6)
WARNING: CIDER requires nREPL 0.2.7 to work properly
user> 

The warning message clearly says that I have to upgrade nrepl to 0.2.7, however, I don't know how.

I installed leiningen via brew, and it uses nrepl 0.2.6.

$ lein repl
nREPL server started on port 53218 on host 127.0.0.1 - nrepl://127.0.0.1:53218
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_31-b13
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>

The content of leiningen profile is:

{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]}}

Question:: How to upgrade the version of nrepl used by leiningen?

Freemasonry answered 24/2, 2015 at 5:25 Comment(2)
CIDER will work even with older nREPL versions but there are some subtle and not so subtle bugs in them. Someone should really update the nREPL bundled with lein and reply.Uranie
Seems nREPL is already updated in lein's master.Uranie
N
56

I've just had this problem, and I solved it by adding an explicit dependency on the newer version of tools.nrepl to profiles.clj. My ~/.lein/profiles.clj:

{:repl {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.7"]]}}

No idea whether that's the best or official way to do it, tho'.

Noyade answered 24/2, 2015 at 6:0 Comment(5)
See github.com/clojure-emacs/cider/issues/970 Seems that nRepl prio to 2.7 has some bugs. I think this dependency has been updated in lein master, but perhaps not yet released, so adding the dependency on later version is probably right fix, though you probably want to remove that dep after next lein updateArvie
A note... This worked for me provided the dependency was in profiles.clj as opposed to the project's project.clj.Supersonics
With that exact profiles.clj, lein downloads the nrepl 0.2.7 files, but still starts up nrepl 0.2.6, for me. On both a Windows 7 box and OS X.Ashford
@ShannonSeverance I suspect you made the mistake I did, which is placing the tools.nrepl version vector inside the :plugins vector rather than the :dependencies vector ...Shoop
See peterfoldi's answer for an update that seems to be required now.Dilation
M
9

lein has an upgrade command so in the simplest case

lein upgrade

In case you installed leiningen with a package manager you might need to do something like the below (example for OS X, linux distros have their own wonderful package managers):

brew unlink leiningen
brew update
brew install leiningen
Medicine answered 30/9, 2015 at 19:18 Comment(1)
This worked for me. I recently updated my OS to el.capitan but didn't update leiningen. So, cider nRepl started complaining. Thank you for this help.Photoluminescence
C
8

an additional note on top of @matthew-moss's: the tools.nrepl dependency line is only used if you run lein repl from within a clojure project. if you just run lein repl from your home directory, for example, you end up using the version of tools.nrepl that is compiled into leiningen. No idea why.

Hope that saves somebody time.

Clava answered 9/5, 2015 at 11:24 Comment(0)
B
3

As an addition to the accepted answer: adding dependency on 0.2.7 in user profiles.clj worked for me some days ago but then suddenly I got back to the 0.2.6 warning. Asking "lein deps :tree" had this line in it:

[org.clojure/tools.nrepl "0.2.7" :scope "test" :exclusions [[org.clojure/clojure]]]

Which gave me a clue that probably the lein-test-refresh plugin (defined in the same profiles.clj) is causing some confusion here. Reading some more about profiles I learnt about the ^:replace hint. This line in dependencies works now for me:

^:replace [org.clojure/tools.nrepl "0.2.7"]
Backbite answered 6/4, 2015 at 17:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.