TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using LaTeX pdfTeX 3.1415926-1.40.9-2.2 on Mac OSX 10.6. When I try to build from TextMate (Ctrl+R) I get the following error:

Please add the directory containing “kpsewhich” to PATH in TextMate's Shell 
Variables preferences. 
share|improve this question
Just to be clear: you are using Textmate to run a shell? – Charles Stewart Nov 9 '10 at 7:14
which OS and which LaTeX distribution? – Juan A. Navarro Nov 9 '10 at 12:00
up vote 7 down vote accepted

open up the file ~/.bash_profile and add the following to the end

export PATH

This should patch the issue.

NOTE 1: To open the ~/.bash_profile open terminal and type mate ~/.bash_profile or vim ~/.bash_profile

NOTE 2: The PATH could be located elsewhere for you as mentioned in one of the comments bellow


  • mate is the command line or bash call to TextMate.
  • vim is the bash call to vim (an command line editor).
  • ~ is the bash reference to your home directory.
  • a . before a file is UNIX's (What OSX runs on) way of specifying a hidden file, which is why you can't see the .bash_profile in your home folder.
share|improve this answer
Hey Ban, How do you open up the file ~/.bash_profile? – Helen Nov 13 '10 at 3:30
in my case the path was at "/usr/local/texlive/2008/bin/universal-darwin" so here is how I set the PATH in my .bash_profile: PATH="/usr/local/texlive/2011/bin/universal-darwin:${PATH}" – Greenish Dec 15 '15 at 3:02

How about: go to 'Preferences' in TextMate, and add /usr/texbin to the PATH in the 'Shell Variables'? After all, that is what TextMate itself suggests ...

share|improve this answer
Adding that path directly to your bash profile makes LaTeX, TeX, etc accessible not only from TextMate, but also from Terminal or any other program that accesses programs through the command line. – Ben Nov 15 '10 at 22:27

I had the same error message. In my case I did the following which solved the problem :

  1. Locate kpsewhich using find / -name kpsewhich* -print. In my case, the kpsewhich executable is located at /usr/local/texlive/2008/bin/universal-darwin.

  2. Add the path to the PATH variable in TextMate. In TextMate go to Preferences... > Advanced > Shell variables. Add :/usr/local/texlive/2008/bin/universal-darwinto the existing value of PATH variable.

  3. Do cmd+r and it worked. No need to restart anything.

share|improve this answer
Welcome to TeX.SX! – Adam Liter Sep 7 '14 at 15:28
I am aware that this is an old thread, but just for future reference for anyone having the same problem, this worked for me! My kpsewhich file was in exactly the same location too. Thank you! – surelyourejoking Oct 26 '15 at 2:19

Neither of these path-setting options worked directly for me. Not even after restarting Textmate 2.

However, I noticed that there was a little check box next to the PATH - the first line in Textmate - Preferences - Variables. Checking that box immediately resolved the problem. I had previously run

which kpsewhich

from the command prompt and added its path to both ~/.bashrc and the PATH text value. That editing that field didn't automatically check the box or ask if I wanted it checked is well just one of those things that might have been nice for the developers to have thought of as being useful.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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