7

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

DJG
  • 6,413
  • 4
  • 30
  • 51
  • which version of emacs? To rule out any environment woes I'd recommend starting with the emacs starter kit package and Emacs 24. – leonardoborges Aug 13 '13 at 12:41
  • 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 Aug 13 '13 at 12:44
  • 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 Aug 13 '13 at 13:18
  • Leiningen 2.1.2 on Java 1.6.0_27 OpenJDK 64-Bit Server VM – DJG Aug 13 '13 at 13:20
  • I had some problems once when I installed a whole bunch of clojure related things from the emacs package manager. I looked at the package manager and got a bit trigger happy. I guess things started to conflict. Now I use Emacs Live, and haven't looked back. In theory you just need clojure-mode and nrepl.el, might be worth checking your version of clojure-mode is up to date, and you've got no old slime/swank things kicking around. – Daniel Neal Aug 13 '13 at 13:32
  • Tried it on my machine without problem. What do you see in your \*Messages\* buffer. I have: Starting nREPL server... nREPL server started on 34325 Connecting to nREPL on localhost:34325... Connected. May the Source shine upon thy nREPL! – Nicolas Dudebout Aug 13 '13 at 17:12
  • I have this exact bug, I will report back if I find a fix. I tried multiple emacs versions, multiple versions of nrepl... I have had nrepl work in the past on another computer, but somehow it is broken on this one. – noisesmith Aug 13 '13 at 20:27
  • 1
    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 Aug 13 '13 at 20:37

1 Answers1

3

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.

noisesmith
  • 20,076
  • 2
  • 41
  • 49