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

Broken: cider-eval-defun-at-point needs a Clojure REPL #1611

Closed
arichiardi opened this issue Mar 8, 2016 · 23 comments
Closed

Broken: cider-eval-defun-at-point needs a Clojure REPL #1611

arichiardi opened this issue Mar 8, 2016 · 23 comments
Labels

Comments

@arichiardi
Copy link
Contributor

Expected behavior

It should evaluate forms from cljs files to cljs repl with cider-eval-defun-at-point

Actual behavior

The form is not evaluated with message:

user-error: `cider-eval-defun-at-point' needs a Clojure REPL.
If you don't know what that means, you probably need to jack-in (`C-c M-j').

Steps to reproduce the problem

In replumb, I can provide a branch, lein repl then connect or jack-in then start a Cljs repl with either:

(require 'figwheel-sidecar.repl-api)
(figwheel-sidecar.repl-api/start-figwheel!)
(figwheel-sidecar.repl-api/cljs-repl)

Same thing with cider-jack-in-clojurescript, of course targeting the cljs repl.

Environment & Version information

CIDER version information

;; CIDER 0.11.0 (Bulgaria), nREPL 0.2.12
;; Clojure 1.7.0, Java 1.8.0_72

Emacs version

24.5

Operating system

Ubuntu Linux

Maybe related: clojure-emacs/cider-nrepl#301

@Malabarba
Copy link
Member

What is the value of cider-repl-type in your cljs repl buffer?

@arichiardi
Copy link
Contributor Author

Steps, hopefully right: open ielm, C-c C-b, choose the repl, then cider-repl-type, result clj.

@arichiardi
Copy link
Contributor Author

@Malabarba By eye bisecting, and then trying, I found that the culprit is 9672dfa

@Malabarba
Copy link
Member

choose the repl

Just to be sure. You did choose the ClojureScript repl, right?

then cider-repl-type, result clj.

Then this is the bug, and it's probably on the Clojure side. The commit you found helped exposed the bug, but didn't cause it.

You should have a couple of nrepl-messages buffer around. Please show us the contents of this buffer for the ClojureScript connection.

@arichiardi
Copy link
Contributor Author

I had chosen the wrong one, I now checked and it is a cljs cider-repl-type. Sorry about that, still the error appears:

Here is nrepl-messages (cut, tell me if you need more):

 (<-- 
  id  "11"
  out  "Prompt will show when Figwheel connects to your application\n"
  session  "6eaf3a92-ca04-49f1-9474-40bbf461152a"
)
(<-- 
  id  "11"
  out  "To quit, type: :cljs/quit\n"
  session  "6eaf3a92-ca04-49f1-9474-40bbf461152a"
)
(<-- 
  id  "11"
  ns  "cljs.user"
  session  "6eaf3a92-ca04-49f1-9474-40bbf461152a"
  value  "nil"
)
(<-- 
  id  "11"
  session  "6eaf3a92-ca04-49f1-9474-40bbf461152a"
  status  ("done")
)
(<-- 
  changed-namespaces  (dict 
                        cljs.analyzer  (dict 
... a lot of stuff
  id  "11"
  repl-type  "cljs"
  session  "6eaf3a92-ca04-49f1-9474-40bbf461152a"
  status  ("state")
)

@alexander-yakushev
Copy link
Member

Same issue for me. cider-repl-type in CLJS repl buffer is "cljs", in a .cljs file it's "clj".

@bbatsov
Copy link
Member

bbatsov commented Mar 10, 2016

How many times can we break this? :-)

@Malabarba
Copy link
Member

The evidence that's been presented so far seems to indicate there's a problem in cider-map-connections (or one of the functions it calls). Unfortunately, I'm unable to reproduce this issue. =/

Does anyone have simple steps for this?
Even better, if one of you would like to edebug and step through cider-map-connections, that would be a huge help. :-)

@alexander-yakushev
Copy link
Member

clojurescript-mode is not automatically enabled for .cljs buffers. When manually enabled, everything works fine again. So, is it a bug with clojure-mode, or my setup is wrong?

@Malabarba
Copy link
Member

Oh. Could be something in your setup. Try with emacs -q + package-initialize.

If it turns out to be from your setup, this kind of thing is a little annoying to debug. The best I can think of would be to look through the auto-mode-alist variable, but that's a pretty big variable.

@bbatsov
Copy link
Member

bbatsov commented Mar 10, 2016

@alexander-yakushev
Copy link
Member

Yes, it's a bug in my setup. Pretty sure it is also the case for @arichiardi .

@bbatsov
Copy link
Member

bbatsov commented Mar 10, 2016

What was the bug in your setup?

@arichiardi
Copy link
Contributor Author

It can be, I am using emacs live and they might be behind in initializing variables. What did you do @alexander-yakushev?

@alexander-yakushev
Copy link
Member

I had custom mode-alist in my (use-package clojure-mode ...) that marked clj[sxc]? as clojure-mode.

@arichiardi
Copy link
Contributor Author

That's probably the same in emacs live, i guess clojurescript-mode is a new thing?

@arichiardi
Copy link
Contributor Author

Thanks @Malabarba, while I am going to fix this now, I will check that your warning works 👯

@arichiardi
Copy link
Contributor Author

I confirm the warning works like a charm, I see it in the Messages buffer. I am now going to fix this.

@bbatsov
Copy link
Member

bbatsov commented Mar 10, 2016

OK, so I guess we can close this. Teamwork for the win! :-)

@bbatsov bbatsov added the bug label Mar 10, 2016
@bbatsov bbatsov closed this as completed Mar 10, 2016
@arichiardi
Copy link
Contributor Author

Yes I confirm this works and I patched my emacs-live in order to remove this.

@kthu
Copy link

kthu commented Jun 13, 2016

I know this issue is closed, but I'll just put the following up here for future reference;

For me this problem consistently shows up in the latest version of Cider (20160612.1230) if clj-refactor is installed. It worked fine in the previous version (I guess before the workaround in e2f9ffd), but I have struggled with this problem in earlier versions.

I am using Spacemacs where clj-refactor is part of the Clojure layer, but I was able to reproduce the problem starting with an empty .emacs.d after installing Cider and clj-refactor only. Deleting clj-refactor from the elpa/ directory fixes the problem.

This is using Emacs 24.5.1 on Ubuntu 16.04

@Malabarba
Copy link
Member

I've deployed a possible fix for this. Let me know if it works for you (make sure lein fetches today's snapshot).

@kthu
Copy link

kthu commented Jun 13, 2016

Yes. That fixed it! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants