I just installed MacTeX onto Yosemite and it installed everything in usr/local/texlive
However if I am in Terminal and try to compile a LaTeX file with pdflatex foo.tex
, it cannot find the LaTeX tools. Further whereis pdflatex
returns no results.
If I specify the entire path of pdflatex
(e.g., /usr/local/texlive/2014/.../bin/pdflatex
) it all works well.
How can I get the LaTeX tools to work from the terminal without specifying the entire path?
Best Answer
For binaries to be accessible from the command line, their locations must be part of the
PATH
environment variable. If you do the following(filling in the correct path), you will be able to call
pdflatex
directly (as well as every other program in the same directory. To make the change permanent,export
the command in a file sourced by the shell, such as.bash_login
or.profile
(assuming you use bash). Either use an editor or runWhich will append the output of the
echo
command to the file and create it if it does not exist.The shell searches the directories in the
PATH
in the order they are listed, so usually it is a good idea to always append to thePATH
unless you know exactly what is in the added directory. It might contain other executables with the same name as other programs which are already in thePATH
. Having these shadowed can sometimes lead to surprises.