My .emacs contains
(setenv "PATH" (concat ".:/usr/texbin:/opt/local/bin" (getenv "PATH")))
(setq exec-path (append exec-path '(".:/usr/texbin:/opt/local/bin")))
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp")
(require 'tex-site)
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
/usr/texbin is where latex/pdflatex/.. are located. /opt/local/bin/ is where gs can be found.
And yet when I run preview-at-point, which apparently needs both latex and gs, I get
Preview-DviPS finished at Thu Dec 22 11:25:46
DviPS sentinel: Searching for program: No such file or directory, gs
which means that latex could be found all right, but not gs.
I am not sure whether setting exec-path is necessary, perhaps PATH is enough, but I've set it as a debugging measure.
Why can emacs not find gs even though the directory it's in is in both PATH and exec-path?
If you're setting
$PATH
inside your Emacs, you might well be on OS X. GUI applications are not started via your shell, so they see different environment variables.Here's a trick which I use to ensure the
$PATH
inside Emacs is the same one I see if I fire up a terminal (but see "update" below):Then simply call the
set-exec-path-from-shell-PATH
function, perhaps from your Emacs init file. I keep that code on github, BTW.Update: this code has now been improved and published as an elisp library called exec-path-from-shell; installable packages are available in MELPA.
I hit a similar problem, but with a correct PATH, including trailing ´:´. It turned out the internal emacs shell program was missing, resulting in a ´Searching for program: No such file or directory´ message. Fixed with
It appears you're missing a path separator
:
at the end of your path string.Try replacing the second line with this: