1

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?

2

For binaries to be accessible from the command line, their locations must be part of the PATH environment variable. If you do the following

PATH=$PATH:/usr/local/texlive/2014/.../bin

(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 run

echo "export PATH=$PATH:/usr/local/texlive/2014/.../bin" >> ~/.bash_login

Which 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 the PATH 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 the PATH. Having these shadowed can sometimes lead to surprises.

| improve this answer | |
3

To get the LaTeX tools to run from the command line, you need to add the path to your pdflatex to your executable search path. To do this, you'll need to edit the .bash_profile file in your home directory. Open the file in a plain text editor (e.g. vi, emacs, bbedit) and add this line at the bottom:

PATH=/usr/local/texlive/2014/.../bin:$PATH

where /usr/local/texlive/2014/.../bin is the path you typed in your example to get pdflatex to run.


An aside

whereis only returns results from system-installed executables. which looks in the entire path. e.g. on my machine:

~ 503 🎵  whereis ruby
/usr/bin/ruby
~ 504 🎵  which ruby
/Users/steve/.rvm/rubies/ruby-2.1.2/bin/ruby
| improve this answer | |

You must log in to answer this question.

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