7
votes

I created a new project with lein. I open core.clj in emacs. I make sure to run M-x clojure-mode, and M-x nrepl-enable-on-existing-clojure-buffers.

Then I run M-x nrepl-jack-in and in the mini-buffer I get

Starting nREPL server...

followed by a message such as:

Connected. You're bound to be unhappy if you optimize everything. -Donald Knuth

I see that the buffer name is *nrepl*, but the buffer does not contain a Clojure Repl and instead is completely blank.

If I type anything (meaning anything at all,) I get:

Wrong type argument: integer-or-marker-p, nil

If I switch back to my core.clj buffer, and hit C-c C-l,I get the namespaced name of the last function in my buffer in the minibuffer as a result. And if I put my cursor at the end of a function definition and hit C-x C-e, I get:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:1:1)

I tried making a new lein directory with no dependencies using lein new project-name and tried the same steps as above and got the same results.

What else can I check and/or what am I doing wrong?

EDIT: Additional Information

When I type something into the empty *nrepl* buffer and try to press C-x C-e on what I typed, in the mini buffer I get the message:

No Lisp subprocess; see variable `inferior-lisp-buffer'

Also, I am running:

GNU Emacs 24.3.1

Leiningen 2.1.2 on Java 1.6.0_27 OpenJDK 64-Bit Server VM

1
which version of emacs? To rule out any environment woes I'd recommend starting with the emacs starter kit package and Emacs 24.leonardoborges
Try to launch the repl server in an external shell, connnect with just nrepl. Also, deactivate as many minor modes (auto-completion etc.) as possible and temporarily rename leiningen profiles.clj in ~/.lein/. If that gives you a working REPL, step-wise enable features.Leon Grapenthin
I've tried exactly your steps and it works fine for me. You're not doing anything wrong (although of your steps, all I normally have to do is nrepl-jack-in, clojure-mode is associated with .clj files and I wasn't even aware of nrepl-enable-on-existing-clojure-buffers). Are you using lein 2?Daniel Neal
Leiningen 2.1.2 on Java 1.6.0_27 OpenJDK 64-Bit Server VMDJG
More information: I relocated all packages I had installed related to clojure (nrepl, clojure mode, etc.), created a brand new user with a nearly empty .emacs, and used package/marmalade to install clojure mode and nrepl, and this bug does not go away. Update: I somehow missed something. By completely emptying my .emacs.d, and reinstalling clojure-mode and nrepl, I somehow got rid of something that was provoking this bug.noisesmith

1 Answers

3
votes

I just fixed this exact issue on my own setup. Move your .emacs.d to a backup location, and make a backup copy of your .emacs. Make a new .emacs with only the following lines:

(require 'package)

(add-to-list 'package-archives 
    '("marmalade" .
      "http://marmalade-repo.org/packages/"))

(package-initialize)

(require 'clojure-mode)

(require 'nrepl)

Once you install nrepl and clojure-mode via running M-x package-list-packages and installing their respective entries, you will be able to use nrepl.

Add your custom .emacs back in one logical unit at a time, and you should be able to figure out where the conflict was and eliminate it. Be suspicious of anything related to slime / swank.