Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jwr opened this issue May 8, 2018 · 11 comments
Closed

Comments

@jwr
Copy link

@jwr jwr commented May 8, 2018

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.

@bbatsov

This comment has been minimized.

Copy link
Member

@bbatsov bbatsov commented May 8, 2018

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)
@jwr

This comment has been minimized.

Copy link
Author

@jwr jwr commented May 8, 2018

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!

@bbatsov

This comment has been minimized.

Copy link
Member

@bbatsov bbatsov commented May 8, 2018

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!

@bbatsov bbatsov closed this May 8, 2018
@zhongwm

This comment has been minimized.

Copy link

@zhongwm zhongwm commented May 29, 2018

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?

@flyingmachine

This comment has been minimized.

Copy link

@flyingmachine flyingmachine commented Jun 23, 2018

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

@Aberrantfox

This comment has been minimized.

Copy link

@Aberrantfox Aberrantfox commented Jan 5, 2019

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

@bbatsov

This comment has been minimized.

Copy link
Member

@bbatsov bbatsov commented Jan 5, 2019

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.

@doyougnu

This comment has been minimized.

Copy link

@doyougnu doyougnu commented Jan 22, 2019

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
     ...
@jbf

This comment has been minimized.

Copy link

@jbf jbf commented Jan 25, 2019

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 !!

@kuberlog

This comment has been minimized.

Copy link

@kuberlog kuberlog commented Apr 1, 2019

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

@natethe338

This comment has been minimized.

Copy link

@natethe338 natethe338 commented Apr 6, 2019

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.

JpOnline added a commit to JpOnline/figwheel-main that referenced this issue Aug 8, 2019
I was having the following error with the previous version.

Unable to resolve var: session/session-ou[148/1882]
context
clojure-emacs/cider#2284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.