4 followers Follow

pdflatex error on OSX

Hi there,

When attempting to run knitr in R Studio (from OSX - I'm currently running the Yosemite beta but I get the same errors in my Mavericks partition) I get the following error:

pandoc: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed with error 41
Execution halted

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

Windows: MiKTeX (Complete) -
(NOTE: Be sure to download the Complete rather than Basic installation)

Mac OS X: TexLive 2013 (Full) -
(NOTE: Download with Safari rather than Chrome strongly recommended)

Linux: Use system package manager

Also, when attempting to run texi2dvi, I get the error:

Error in texi2dvi("samplefile.tex", pdf = TRUE) :
Running 'texi2dvi' on 'samplefile.tex' failed.

What I don't understand is that running the same texi2dvi command works just fine when I run R from terminal. But in any GUI environment none of the TeX commands work.

From R console, if I run Sys.getenv("PATH") it returns the following:


So, texbin is there, and in /usr/texbin I see both "texi2dvi" as well as "pdflatex". I've checked other solutions on the forum, reinstalled MacTex, R, RStudio and nothing seems to work. Any help would be appreciated.



Matt Abbott

Please sign in to leave a comment.



My office mate suggested that I create a symbolic link to pdflatex by opening a shell and entering the following command:

sudo ln -s /usr/texbin/pdflatex /usr/bin/pdflatex

I did the same for texi2dvi and that helped as well. There is an additional issue that sweave.sty is located in the wrong directory, and there are several solutions to that available through a quick search.

Matt Abbott 1 vote

I had the same problem, and the following two symbolic links fixed it:

sudo ln -s /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin /usr/texbin
sudo ln -s /usr/texbin/pdflatex /usr/bin/pdflatex

Not sure that it matters, but I am using TeXShop, and didn't have to re-install anything.

Dave Dyer 2 votes