(Cider) How do I use refactor-nrepl from a deps.edn project?


I’ve stumbled into this warning when having Cider connect to a running Clojure REPL:

WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20190516.1254) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.

Does anyone know how to set up a deps.edn project so that CIDER is happy with its dependencies? My current deps.edn file looks like this:

{:paths ["resources" "src"]
 :deps {org.clojure/clojure {:mvn/version "RELEASE"}}
 {:test {:extra-paths ["test"]
         :extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}}
  :cider {:extra-deps {cider/cider-nrepl {:mvn/version "0.22.0-beta4"}
                       refactor-nrepl {:mvn/version "2.4.0"}}
          :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}

, and I then start my REPL server with

clj -A:test:cider




If you jack-in to the project, CIDER tells you what command line it uses and thus what dependencies are needed.

Thanks for the hint! Off to check those *cider-repl* and *Messages* buffers.

Update: found this in *Messages*

[nREPL] Starting server via /usr/local/bin/clojure -Sdeps ‘{:deps {nrepl {:mvn/version “0.6.0”} cider/cider-nrepl {:mvn/version “0.22.0-beta4”}}}’ -m nrepl.cmdline --middleware ‘[“cider.nrepl/cider-middleware”]’…

With the dots (…) literal. Does that mean the command got “cut off”?

Disclaimer: I am a huge fan of CIDER, but not user. I distill it before consumption. (Hint: Calva is distilled from Cider.)

Last time I used Cider jack-in it prompted me with the command line it was going to execute, giving me a chance to alter it. Maybe that is a setting?

Also, it does look like Cider is picking up cider/cider-nrepl {:mvn/version “0.22.0-beta4”} from your deps.edn. What happens if you remove all references to cider dependencies from the project file before you jack in?

Yeah, I was expecting you to use Calva! I appreciate any pointers regardless. Still after having used Cider for a while, I feel like there’s magic going on in the background.

I fired up cider-jack-in with this small deps.edn:

{:paths ["resources" "src"]
 :deps {org.clojure/clojure {:mvn/version "1.10.0"}}}

which gave me this message in the *Messages* buffer:

[nREPL] Starting server via /usr/local/bin/clojure -Sdeps ‘{:deps {nrepl {:mvn/version “0.6.0”} cider/cider-nrepl {:mvn/version “0.22.0-beta4”}}}’ -m nrepl.cmdline --middleware ‘[“cider.nrepl/cider-middleware”]’…

… which is what I was using above.

Sidenote. I’ve never been a hard user of refactor-nrepl within other projects, but I’d really like to have a dependable rename-variable refactoring. I guess I could fire up something like Cursive if there are more references than I’d be able to handle with a normal find-and-replace in my editor.

Thanks for the help!

You’re welcome. This sparked my interest because I’m pondering some refactor support in Calva. Rename variable will be first, for sure.

Good that CIDER wasn’t picking that up from the project file. I was wondering what kind of crazy reason @bbatsov would have for that. :grinning:

Btw, a reason Calva gets away, somewhat, without refactoring support is that VS Code has amazing search/replace functionality. It has yet not been painful enough for me (and apparently anyone else) to make me prioritize the work with implementing proper refactoring.

Reading the OP again. That looks like a bug. Have you checked the open issues?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.