I have installed MacTex and GNU Emacs on my iMac. I have created a simple tex file (the one suggested here) and tried to run LaTeX on it by hitting C-c C-c, but the following message appeared:

ERROR: AUCTeX cannot find a working TeX distribution.
Make sure you have one and that TeX binaries are in PATH environment variable.
If you are using OS X El Capitan or later
remember to add /Library/TeX/texbin/ to your PATH

Opening Terminal and running

echo $PATH



Operating system: macOS Sierra, Version 10.12.4
Emacs version: 25.1.1
AUCTeX version: 11.90.0
MacTex distribution: MacTeX-2016

  • 2
    Terminal may have a different PATH than Emacs, try evaluating (getenv "PATH") in the scratch buffer to check. – nohillside Mar 29 '17 at 8:52
  • @patrix Could you make your comment an an answer so people know that the question has been addressed. – Tony Williams Mar 29 '17 at 10:19
  • My comment isn't an answer, just a debugging step. The answer should explain how to set the path for Emacs, or how to configure AucTeX correctly (I'm sure there are some variables/hooks to point AucTeX to the TeX installation). – nohillside Mar 29 '17 at 11:22

As patrix suggested, the problem was that the PATH variable that the error message referred to was not the Terminal's environment variable but emacs' own environment variable, whose content can be seen (as suggested by patrix) by evaluating (getenv "PATH") in Emacs.

To add /Library/TeX/texbin/ to emacs' PATH variable, I added the following code to the emacs initialization file .emacs:

(setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin/"))  
(setq exec-path (append exec-path '("/Library/TeX/texbin/")))

These lines of code are appropriately modified versions of the ones given here.

After restarting Emacs, the problem was gone.

| improve this answer | |

The problem you are having is because Emacs does not get the $PATH variable when it is started from the Finder and therefore does not set exec-path properly.

An easy solution is to install the Emacs package execpath-from-shell

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .