1

Newbie Clojure programmer here. NREPL in Emacs isn't working for me.

  • Aquamacs 2.5 (Emacs 23.4.1)
  • nrepl.el 0.1.8
  • Leiningen 2.2.0 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM

My project is just the lein-generated Hello World.

Running "lein repl" in a shell works, but nrepl.el doesn't work. Rather than winding up in the project's namespace in the repl, I just get the default toplevel in the "user" namespace.

Should see something like:

my$ lein repl
nREPL server started on port 57347
REPL-y 0.2.0
Clojure 1.5.1
Hello Project
my.core=> 

But instead see:

; nREPL 0.1.8-preview
user> (in-ns my.core)
CompilerException java.lang.ClassNotFoundException: my.core, compiling:(NO_SOURCE_PATH:1:1)
user> 

In a clean nrepl.el scenario, I see two java processes going and they look plausible. One has my project on the -classpath and is implementing the actual repl (server), while the other is the client side java (-D MyProjectPath -m leiningen.core.main repl :headless).

I get the same lossage whether I get there by m-x nrepl-jack-in or starting in the shell and then m-x nrepl. I get a repl that doesn't know my project.

I wonder if this stuff works for anyone, or if I have something installed or set up wrong? Lots of "0.xxx" versions of things going on here...

user1698584
  • 91
  • 1
  • 7

2 Answers2

1

Looks like you are missing a quote before your namespace, try the following:

(in-ns 'my.core)

Note the ' before my.

aldazosa
  • 345
  • 3
  • 5
  • Oh! I thought it was a macro like in CL. Thanks! Now it looks like nrepl-jack-in is working, and my problem is reduced to why it's not starting in the project namespace in the first place and ignoring the :repl-options. – user1698584 Jul 05 '13 at 18:09
  • 1
    nrepl does not respect leiningen's repl-options. There is an elisp workaround here: https://github.com/kingtim/nrepl.el/issues/316 – aldazosa Jul 06 '13 at 03:44
1

NRepl always starts in the top-level user namespace. Use M-x nrepl-set-ns, or C-c M-n in a Clojure buffer, to set the namespace of NRepl to the one of the buffer.

In your specific case,

  • visit src/my/core.clj, press C-c M-j to start NRepl,
  • switch back to the src/my/core.clj buffer,
  • press C-u C-c C-z to set the NRepl namespace to my.core and switch back to the NRepl buffer.

C-u C-c C-z is a shortcut for C-c M-n followed by C-c C-z to switch to the NRepl buffer.