Elisp: exec-path, External Program Search Paths
exec-path
- exec-path
-
List of dir paths to search external programs. An element may be
nil, it means default-directory.By default the last element of this list is exec-directory (the emacs bin dir.) .
Emacs uses exec-path to find executable binary programs.
For example,
- Alt+x
difftries to find unixdiff - Alt+x
greptries to find unixgrep - Alt+x
shelltries to find unixbashif emacs is on linux. - Alt+x
dired-do-compresstries to find unixgzip - Alt+x
ispell-wordtries to find unixispelloraspell
By default, emacs copies the value of (getenv "PATH") to exec-path. So, their values should be identical.
Here's a example of setting exec-path:
(when (eq system-type 'windows-nt) (push (expand-file-name "~/bin/oxipng/") exec-path))
Difference between exec-path and PATH
- The value of environment variable “PATH” is used by emacs when you are trying to call a linux command from a shell in emacs.
- The exec-path is used by emacs itself to find programs it needs for its features, such as spell checking, file compression, compiling, grep, diff, etc.
The value of (getenv "PATH") and exec-path do not need to be the same.