Can't launch `lein` REPL in Emacs

我的梦境 提交于 2019-12-21 03:30:32

问题


In Emacs, when using clojure-mode, I ought to be able to launch a REPL with C-c C-z. Whenever I try, though, I get the error:

Searching for program: no such file or directory: lein

I have lein installed in /usr/local/bin (via brew) and /usr/local/bin is in my PATH (even Emacs says so, via eval-expression (getenv "PATH")).

What am I missing?


回答1:


Ah! The PATH environment variable isn't the end-all and be-all of emacs search paths. There's also the "exec-path". It apparently does mostly the same thing but not exactly.

Anyway, adding:

(add-to-list 'exec-path "/usr/local/bin")

To my .emacs.d/init.el (or .emacs if that's how you roll) cleared things up for me. The doc linked above suggests something a little more comprehensive, like:

(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))

I'd try the (simpler) add-to-list, first. But YMMV.




回答2:


I had the same problem and started to investigate what was wrong. I soon discovered my exec-path looked like this (simplified example):

("/usr/local/bin /bin /sbin").

It was a list with just one long string instead of a list of separate paths. My env PATH variable looked exactly the same. Obviously the problem was coming from my shell.

I use fish-shell. It's PATH variable separator is just a space. The exec-path-from-shell package I use can't parse it. I fixed it by appending this to my .emacs.d/init.el:

(setq exec-path (split-string (car exec-path)))

Update: In the end it was an outdated exec-path-from-shell package. Use version 1.8. It works well with fish (and tcsh).



来源:https://stackoverflow.com/questions/13671839/cant-launch-lein-repl-in-emacs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!