Mac OSX, Emacs 24.2 and nrepl.el not working
Asked Answered
X

4

10

I'm using nrepl.el, Emacs 24.2. My S.O version is OS X Lion 10.7.5.

Running the command [M-x] nrepl after start a REPL session through lein (:~ $ lein repl) i am able to connect to it but if i try to use [M-x] nrepl-jack-in i get the message bellow:

error in process sentinel: Could not start nREPL server: /bin/bash: lein: command not found

I installed leiningen using the instructions in the main site and reinstalled it using homebrew with the command brew install leiningen --devel but both methods give me the same error.

Adding the path /usr/loca/bin to emacs exec-path list or trying to configure nrepl.el variable nrepl-lein-command to point to the full path of my lein installation does not help.

My emacs configuration can be found here: https://github.com/khaoz/emacs-files

What i'm doing wrong ?

Thanks :)

Xiphisternum answered 6/11, 2012 at 1:19 Comment(3)
are you by chance on a Mac and staring emacs not from the command line?Nutt
no. I start it from spotlight.Xiphisternum
Just a warning in advance, if you're ever planning to use ac-nrepl - at least at the moment it seems to sometimes do wonky things when you started the server with nrepl-jack-in. Maybe they fixed this by now, just recall it if you run into problems.Gemoets
N
12

for those of you landing on this question who are using a Mac:

lein needs to be on the path as seen by Emacs. This can be done by starting Emacs from bash

/Applications/Emacs.app/Contents/MacOS/Emacs project.clj

then: M-x nrepl-jack-in

If this solves the problem you can configure emacs to use the correct path by following these instructions

Nutt answered 6/11, 2012 at 1:26 Comment(4)
Yep. Your answer is right. But is there a way to start emacs from spotlight or dock and get nrepl-jack-in to work ?Xiphisternum
Just to add more information, instead of editing the system file /etc/profile, creating or changing the file ~/.profile also works but it will apply the change only for the current user.Xiphisternum
I just had this exact problem on Ubuntu too. Thanks Arthur.Weisman
as a folowup nrepl mode is being replaced by cider-mode. so it's M-x cider-jack-in now though this answer should apply equally well to ciderNutt
J
13

While @Arthur is correct a much simpler solution to your problem would be to install the exec-path-from-shell Emacs extension. It will copy your shell PATH (and MANPATH) to Emacs automatically and fairly reliably. This means that the PATH would be correct no matter where you started Emacs from (spotlight included).

Jacobson answered 6/11, 2012 at 6:18 Comment(0)
N
12

for those of you landing on this question who are using a Mac:

lein needs to be on the path as seen by Emacs. This can be done by starting Emacs from bash

/Applications/Emacs.app/Contents/MacOS/Emacs project.clj

then: M-x nrepl-jack-in

If this solves the problem you can configure emacs to use the correct path by following these instructions

Nutt answered 6/11, 2012 at 1:26 Comment(4)
Yep. Your answer is right. But is there a way to start emacs from spotlight or dock and get nrepl-jack-in to work ?Xiphisternum
Just to add more information, instead of editing the system file /etc/profile, creating or changing the file ~/.profile also works but it will apply the change only for the current user.Xiphisternum
I just had this exact problem on Ubuntu too. Thanks Arthur.Weisman
as a folowup nrepl mode is being replaced by cider-mode. so it's M-x cider-jack-in now though this answer should apply equally well to ciderNutt
M
2

If you are seeing this error in Linux, you may need to set your PATH in ~/.bash_profile instead of ~/.bashrc when running emacs from the menu instead of the shell.

Middleaged answered 22/3, 2013 at 23:14 Comment(0)
B
1

I had to do this:

;; set the path as terminal path [http://lists.gnu.org/archive/html/help-gnu-emacs/2011-10/msg00237.html]
(setq explicit-bash-args (list "--login" "-i"))

;; fix the PATH variable for GUI [http://clojure-doc.org/articles/tutorials/emacs.html#osx] 

(defun set-exec-path-from-shell-PATH ()
  (let ((path-from-shell
         (shell-command-to-string "$SHELL -i -l -c 'echo $PATH'")))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))

(when window-system (set-exec-path-from-shell-PATH))
Backwards answered 31/3, 2013 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.