TextMateAndThePath

Try this in Terminal:

echo $PATH

On my machine, this prints:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin

The PATH is a :-separated list of directories that tells the shell where to look for executable files. Now, let's run a command:

ruby -e 'puts ENV["_"]'

On my machine, this prints:

/usr/bin/ruby

The shell has resolved the filename ruby to a filepath /usr/bin/ruby! There is an important distinction here: the filename ruby and the filepath /usr/bin/ruby. There can be many files named ruby on the system, but only one file can exist at the path /usr/bin/ruby. When you run the command ruby, the shell searches the directories listed in the PATH variable (from left to right) until it finds a file named ruby. Then the shell executes that file with whatever arguments you have specified.

Older versions of TextMate sourced the shell profile when running commands so that TextMate's PATH would be the same PATH as you get in Terminal. This convenience ended up causing all sorts of interesting side effects. Often users would put something “unexpected” in their shell profile that would cause TextMate commands to stop working.

As of build 1489, TextMate no longer sources the user’s shell profile. This means that PATH must be maintained in TextMate's Shell Variables preferences.

In TextMate, I have set my PATH to:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin

If I install something via macports to /opt/local/bin, I'll add that directory to the front of my PATH:

/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin