I'll keep this short and sweet; Emacs can't find gs
, which has been installed via brew and works fine.
Error
PDF2DSC sentinel: Searching for program: No such file or directory, gs
MWE
\documentclass{article}
\begin{document}
This is a test. $x^4$.
\end{document}
And my PATH
after init: "/usr/local/bin:/usr/texbin:/usr/local:/usr/bin:/bin:/usr/sbin:/sbin"
brew
placed a symlink to Ghostscript under /usr/local/bin
->
/usr/local/Cellar/ghostscript/9.06/bin/gs
. (Adding this directory doesn't help.)
Is this a problem with preview
in some way, or is it a problem with Emacs itself? (I should note that running the shell command directly (M-! gs
) works as expected, and running psf2dsc
manually also seems to work as expected (no errors, mwe.dsc
produced).)
Per @Charles' request, echo $PATH
produces /usr/local/bin:/usr/texbin:/usr/local:/usr/local/Cellar/ghostscript/9.06/bin:/usr/bin:/bin:/usr/sbin:/sbin
under M-x eshell
.
Per @Charles' request, M-x preview-report-bug
produces
Emacs : GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
of 2012-08-27 on bob.porkrind.org
Package: 11.86
current state:
==============
(setq
AUCTeX-version "11.86"
LaTeX-command-style '(("" "%(PDF)%(latex) %S%(PDFout)"))
image-types '(png gif tiff jpeg xpm xbm pbm)
preview-image-type 'png
preview-image-creators '((dvipng
(open preview-gs-open preview-dvipng-process-setup)
(place preview-gs-place)
(close preview-dvipng-close))
(png (open preview-gs-open) (place preview-gs-place)
(close preview-gs-close))
(jpeg (open preview-gs-open)
(place preview-gs-place) (close preview-gs-close))
(pnm (open preview-gs-open) (place preview-gs-place)
(close preview-gs-close))
(tiff (open preview-gs-open)
(place preview-gs-place) (close preview-gs-close))
)
preview-dvipng-image-type 'png
preview-dvipng-command "dvipng -picky -noghostscript %d -o \"%m/prev%%03d.png\""
preview-pdf2dsc-command "pdf2dsc %s.pdf %m/preview.dsc"
preview-gs-command "gs"
preview-gs-options '("-q" "-dSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted"
"-dTextAlphaBits=4" "-dGraphicsAlphaBits=4")
preview-gs-image-type-alist '((png png "-sDEVICE=png16m")
(dvipng png "-sDEVICE=png16m")
(jpeg jpeg "-sDEVICE=jpeg")
(pnm pbm "-sDEVICE=pnmraw")
(tiff tiff "-sDEVICE=tiff12nc"))
preview-fast-conversion t
preview-prefer-TeX-bb nil
preview-dvips-command "dvips -Pwww -i -E %d -o %m/preview.000"
preview-fast-dvips-command "dvips -Pwww %d -o %m/preview.ps"
preview-scale-function 'preview-scale-from-face
preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\\PassOptionsToPackage{"
("," . preview-required-option-list)
"}{preview}\\AtBeginDocument{\\ifx\\ifPreview\\undefined" preview-default-preamble "\\fi}\"%' %t")
preview-required-option-list '("active" "tightpage" "auctex"
(preview-preserve-counters "counters"))
preview-preserve-counters nil
preview-default-option-list '("displaymath" "floats" "graphics" "textmath"
"sections" "footnotes")
preview-default-preamble '("\\RequirePackage["
("," . preview-default-option-list)
"]{preview}[2004/11/05]")
preview-LaTeX-command-replacements nil
preview-dump-replacements '(preview-LaTeX-command-replacements
("\\`\\([^ ]+\\)\\(\\( +-\\([^ \\\\\"]\\|\\\\\\.\\|\"[^\"]*\"\\)*\\)*\\)\\(.*\\)\\'" "\\1 -ini -interaction=nonstopmode \"&\\1\" " preview-format-name ".ini \\5")
)
preview-undump-replacements '(("\\`\\([^ ]+\\) .*? \"\\\\input\" \\(.*\\)\\'"
"\\1 -interaction=nonstopmode \"&"
preview-format-name "\" \\2")
)
preview-auto-cache-preamble 'ask
preview-TeX-style-dir "/Users/sean/.emacs.d/elpa/auctex-11.86/latex"
)
Output from running `gs -h':
Followed by a message: Searching for program: No such file or directory, gs
Best Answer
The problem appears to be something related to the complicated way that looking for binaries works in Emacs. It is possible that each of the following will give a different list of bin directories:
H-v exec-path RET
(the "internal" path that is derived from PATH at the time Emacs initialises) (this is where PDF2DSC looks forgs
)M-x eshell RET
followed byecho $PATH
(set to the init PATH, with possible some additional bin directories inserted;eshell
is a program that is a bit like UNIX shell, but is implemented in Emacs Lisp)M-x shell RET
followed byecho $PATH
, which runs a subordinate shell process, which may have additional bin directories inserted when it runs the.shrc
fileAuctex path search is tricky, because it looks for executables in either of two ways, using
TeX-run-command
directly, which depends onexec-path
, and by a invoking subordinate shell, which will depend on the value ofPATH
within that process. Additionally, when running Aquamacs, the application is launched directly using OSX'slaunchd
services, and so the PATH Emacs starts with is independent of the PATH you see at the command line, since the program was not called from any shell.Adding the gv bin directory to
exec-path
might help, or try using a distribution such as Texlive, which has a single bin directory containing bothgs
and thepdftex
, etc., executables.vermiculus' bounty award notice
After checking those directories and applying fixes as necessary,
gs
should start working properly. If after you apply these fixes and a 'Do-Not-Enter' sign appears where images should be, follow:Do one of the following:
.emacs
Evaluate(setq preview-gs-options '("-q" "-dNOSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4"))
, tailoring to your setup. The important bit is changing"-dSAFER"
to"-dNOSAFER"
.(GUI)
"-dSAFER"
to"-dNOSAFER"
(I'm unsure of what this does, but it worked.)As mentioned in the comments, changing this option may be dangerous if you are working with documents that you don't trust; otherwise it is almost certainly safe.