2

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?

SFbay007
  • 1,917
  • 1
  • 20
  • 39

2 Answers2

6

: 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.

syohex
  • 2,293
  • 17
  • 16
  • Thanks syohex...I tried that but did not work. I included the full path....opened a new emacs...tried M-x compile then echo $PATH but could not find the bin path in it. I also tried a couple of binaries from that bin folder but non worked. – SFbay007 Aug 23 '13 at 07:20
  • It works well on my platform(Emacs 24.2, Ubuntu 13.04). Is "~/mybin" really set ? Please check `exec-path` value before executing `M-x compile` by `C-h v exec-path`. – syohex Aug 23 '13 at 08:42
  • You are right. The bin was indeed in the exec-path. But how come when trying to execute a binary doing (M-x compile then "binary name") emacs complain of not recognizing it as a valid command? – SFbay007 Aug 23 '13 at 14:57
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"))
Andreas Röhler
  • 4,804
  • 14
  • 18