Cider: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor when starting 0.17

Created on 8 May 2018  路  11Comments  路  Source: clojure-emacs/cider

Expected behavior

Cider starts.

Actual behavior

Cider does not start after upgrading from 0.16 to 0.17 (no other changes). The backtrace is included below. I was unable to determine the cause. I do not have tools.nrepl in my project.clj.

Starting nREPL server via /usr/local/bin/lein update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] -- update-in :plugins conj \[refactor-nrepl\ \"2.3.1\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.17.0\"\] -- repl :headless :host ::...
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Warning: environ value true for key :is-dev has been cast to string
Error loading refactor-nrepl.middleware: java.io.FileNotFoundException: Could not locate cider/nrepl/middleware/util/misc__init.class or cider/nrepl/middleware/util/misc.clj on classpath., compiling:(refactor_nrepl/middleware.clj:1:1)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context, compiling:(/tmp/form-init2812872348049091938.clj:1:9881)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7010)
    at clojure.lang.Compiler.analyze(Compiler.java:6773)
    at clojure.lang.Compiler.analyze(Compiler.java:6729)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3881)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7005)
    at clojure.lang.Compiler.analyze(Compiler.java:6773)
    at clojure.lang.Compiler.analyze(Compiler.java:6729)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3881)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7005)
    at clojure.lang.Compiler.analyze(Compiler.java:6773)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6368)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7003)
    at clojure.lang.Compiler.analyze(Compiler.java:6773)
    at clojure.lang.Compiler.analyze(Compiler.java:6729)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6100)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5460)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4022)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7001)
    at clojure.lang.Compiler.analyze(Compiler.java:6773)
    at clojure.lang.Compiler.eval(Compiler.java:7059)
    at clojure.lang.Compiler.eval(Compiler.java:7052)
    at clojure.lang.Compiler.load(Compiler.java:7514)
    at clojure.lang.Compiler.loadFile(Compiler.java:7452)
    at clojure.main$load_script.invokeStatic(main.clj:278)
    at clojure.main$init_opt.invokeStatic(main.clj:280)
    at clojure.main$init_opt.invoke(main.clj:280)
    at clojure.main$initialize.invokeStatic(main.clj:311)
    at clojure.main$null_opt.invokeStatic(main.clj:345)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.invokeStatic(main.clj:424)
    at clojure.main$main.doInvoke(main.clj:387)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:702)
    at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context
    at clojure.lang.Util.runtimeException(Util.java:221)
    at clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:720)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7003)
    ... 34 more
Subprocess failed

Steps to reproduce the problem

  1. M-x cider-jack-in

Environment & Version information

CIDER version information

Cider 0.17.0

Lein/Boot version

The project where I am doing the cider-jack-in uses lein, version 2.6.1.

Emacs version

25.3.50.2

Operating system

Linux Ubuntu 16.04.4 LTS.

Most helpful comment

Remove refactor-nrepl - seems you're using a version of it that's not compatible with the current stable CIDER. I guess something like this would be enough:

(setq cljr-inject-dependencies-at-jack-in nil)

All 11 comments

Remove refactor-nrepl - seems you're using a version of it that's not compatible with the current stable CIDER. I guess something like this would be enough:

(setq cljr-inject-dependencies-at-jack-in nil)

Thank you, indeed that was the problem -- I didn't know I was using a version of refactor-nrepl! It wasn't in my project.clj nor ~/.lein/profiles.clj. As it turned out, I had clj-refactor 2.3.1 installed in Emacs, and that was the culprit. After uninstalling it, things work fine.

Thanks for your help!

clj-refactor automatically adds some extra middleware to CIDER and occasionally it's out of sync with the upstream. Anyways, I'm happy we sorted this out quickly!

Hi @bbatsov thanks but after I added (setq cljr-inject-dependencies-at-jack-in nil) at the end of my init.el file, it has no effect, Could you kindly tell me how to set this, thanks?

It looks like another option is to use the lateset clj-refactor snapshot: https://github.com/clojure-emacs/clj-refactor.el/issues/419

I am getting this issue, the suggest fix had other issues. I get this on a completely fresh install of emacs, with a completely fresh install of spacemacs. I'm new to both clojure and emacs, I'm just wondering if there is a way to fix this as it's incredibly irritating

I am getting this issue, the suggest fix had other issues. I get this on a completely fresh install of emacs, with a completely fresh install of spacemacs. I'm new to both clojure and emacs, I'm just wondering if there is a way to fix this as it's incredibly irritating

I don't use Spacemacs, so I've got no idea what exactly it's bundling together. Generally it's best to just run CIDER without any other plugins if you're new to Emacs as their interactions can be confusing for newcomers. It's impossible for a simple disabling of cljr to cause any problems for CIDER itself.

I just came across this. Here is what fixed it for me on a new lein project:

Version stuff:
spacemacs develop branch
lein 2.8.3 (this is the first version to ship with nrepl)
clojure 1.10.0

  1. i removed anything in ~/.lein/profiles.clj which what only what the spacemacs layer said to add (the deps about alembic and tools.nrepl)
  2. I changed my clojure layer variables to include refactor-nrepl in my .spacemacs like this:
     ...
     yaml
     sql
     (clojure :variables
              clojure-enable-fancify-symbols t
              clojure-enable-clj-refactor t) -- added this line
     git
     html
     ...

I just came across this. Here is what fixed it for me on a new lein project:

Version stuff:
spacemacs develop branch
lein 2.8.3 (this is the first version to ship with nrepl)
clojure 1.10.0

1. i removed anything in `~/.lein/profiles.clj` which what only what the spacemacs layer said to add (the deps about alembic and tools.nrepl)

2. I changed my clojure layer variables to include refactor-nrepl in my `.spacemacs` like this:
     ...
     yaml
     sql
     (clojure :variables
              clojure-enable-fancify-symbols t
              clojure-enable-clj-refactor t) -- added this line
     git
     html
     ...

This worked for me as well on spacemacs release branch. Thanks @doyougnu !!

I had the same problem. Upgrading lein from 2.8.2 to 2.9.1 fixed it. I am using nrepl 0.6.0

I am on leiningen 2.9.1

I am guessing Spacemacs deleted nrepl when I went to run the cider jack in command. I am not sure why emacs/spacemacs is allowed to alter my configuration on my system. Because Space basically just broke my leiningen install just from running cider.

I can post more details if needed. But I am not sure if this is cider's fault. My first insinct is...

Don't allow Spacemacs or emacs to delete any packages.

Steps

  1. Run the cider jack in commands in Spacemacs. Then it complains...

Caused by: java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context

  1. Run lein on the command lein...

Caused by: java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/server__init.class, clojure/tools/nrepl/server.clj or clojure/tools/nrepl/server.cljc on classpath.

I tried to reinstall lein with brew. But it's not putting everything back to how I had it. The lein install is now broken. Let me check if I can force homebrew to reset everything for lein.

I tried adding the nrepl package to my project... but it does not work...

https://github.com/nrepl/lein-nrepl

In the meantime, my main suggestion would be to run emacs/spacemacs on a virtualized desktop that you can take snapshots of. And reset to your snapshot in event that your install becomes foobared.

Was this page helpful?
0 / 5 - 0 ratings