问题
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