Auctex – How to Use Auctex in MacOS El Capitan

auctexemacsmacmactex

I'm using GNU Emacs from emacsformacos.com After Migration to OSX 10.11 "El Capitan", Auctex can't run the *tex utilities anymore:

Running `LaTeX' on `poisson' with ``pdflatex  -file-line-error   -interaction=nonstopmode "\input" poisson.tex''
/bin/sh: pdflatex: command not found

There is no problem running for example pdflatex on the shell:

#pdflatex
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex)
 restricted \write18 enabled.

but it seems that auctex calls /bin/sh pdflatex instead, and that does not work anymore:

/bin/sh pdflatex
/Library/TeX/texbin/pdflatex: /Library/TeX/texbin/pdflatex: cannot execute binary file

maybe due to El Capitan's changes to Gatekeeper sandboxing. How can I configure auctex to run pdflatex again?

Best Answer

The problem was the PATH variable that Emacs uses (and passes on to shells it runs) is different from the users PATH variable. To customize Emacs' PATH one can use

(setenv "PATH" "/usr/local/bin:/Library/TeX/texbin/:$PATH" t)

With this change, AucTeX can call the command line programs again. See also this question.

Update (Nov 2015): In AucTeX 11.88.9 another check was installed to see if the command line programs are reachable. Even if the above method works, this check is more restrictive since it looks if the tex binaries are in the emacs path. To pass this check, /Library/TeX/texbin has to be added also to the exec-path variable. To do so, add this to your init file:

(setq exec-path (append exec-path '("/Library/TeX/texbin")))