Adding binary path to emacs $PATH

邮差的信 提交于 2021-02-10 17:28:48

问题


I tried the following:

(setenv "PATH" (concat (getenv "PATH") ":~/mybin"))
(setq exec-path (append exec-path '(":~/mybin")))

But that never worked. I tried M-! and typing one of the binary names and that gave "unknown command" also when doing M-x compile with the binary name same result. M-x compile then echo $PATH gave the path without my ~/mybin folder in it. I am on solaris. What am I doing wrong?


回答1:


: is not needed for exec-path. exec-path is list of directory paths. And you should use absolute paths. You should fix as below.

(setenv "PATH" (concat (getenv "PATH") ":" (expand-file-name "~/mybin")))
(setq exec-path (append exec-path (list (expand-file-name "~/mybin")))

I recommend you to use exec-path-from-shell for setting PATH to Emacs. It provides functions which get environment variables from your login shell and set them to Emacs. It is easy to share environment variables between Emacs and shell.




回答2:


An emacs $PATH doesn't exist. $PATH is a shell variable. Emacs and shell have different name-spaces.

However - as Emacs might read and set $PATH via getenv, setenv - seems no way than looking into the library which access it made.

I'd preferred going with exec-path than.

For examples doing this:

(add-to-list 'exec-path "FULL_PATH_TO_BIN"))


来源:https://stackoverflow.com/questions/18392303/adding-binary-path-to-emacs-path

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