When I try to export an org file to pdf using C-c C-e l o I get the following message:

Saving file /Users/user/tmp/test.tex...
Wrote /Users/user/tmp/test.tex
Processing LaTeX file ./test.tex...
/bin/bash: pdflatex: command not found [3 times]
org-latex-compile: PDF file ./test.pdf wasn't produced

This happens when I open emacs by clicking on the icon that can be found in /Applications. However, if I open emacs from the command line:


I can export the org file without any problem. It seems like in both cases the same init file is loaded and I fail to understand the problem. Any ideas?

NB: version returns:

GNU Emacs 24.4.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21) of 2014-10-21 on builder10-9.porkrind.org

and org-version returns:

Org-mode version 8.2.10 (8.2.10-21-ga712ce-elpaplus @ /Users/drorata/.emacs.d/elpa/org-plus-contrib-20141201/)

Finally, I'm using OS X 10.10.

The $PATH:

I tried to include either (add-to-list 'exec-path "/usr/texbin/pdflatex") or (add-to-list 'exec-path "/usr/texbin") in my .emacs but this didn't help.

  • Something's up with your $PATH. Use which pdflatex from the terminal to find where the program is. As a work around, you can then add this directory to Emacs' path with (add-to-list 'exec-path "/path/to/file")
    – nanny
    Dec 3, 2014 at 19:49
  • @nanny: see my update Dec 3, 2014 at 20:02
  • I would try the path (i.e., a directory) instead of the file / executable itself. Note, you can also change the environmental path: (setenv "PATH" (concat (getenv "PATH") ":/usr/texbin"))
    – lawlist
    Dec 3, 2014 at 20:14
  • @lawlist: I tried both, and it didn't help. Dec 3, 2014 at 20:18
  • What does M-! which pdflatex RET echo?
    – nanny
    Dec 3, 2014 at 20:21

1 Answer 1


Two hints helped me solve the issue:

  1. $PATH and
  2. codename Mavericks

It seems like the problem is indeed related to the path, and the way around it is:

(defun set-exec-path-from-shell-PATH ()
  "Sets the exec-path to the same value used by the user shell"
  (let ((path-from-shell
          "[[:space:]\n]*$" ""
          (shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))

;; call function now

Taken from here and linked to here.

The question why there is a different behaviour between the two emacs opening methods remains unanswered.

  • 2
    There is now a package for this exec-path-from-shell. The difference in the situations is the environment when the command is called. The PATH variable is often modified by the shell when in a terminal from the default in the background system. Dec 20, 2014 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.