TextMateAndThePath

Troubleshooting.TextMateAndThePath History

Show minor edits - Show changes to markup

May 30, 2010, at 23:46 UTC by Alex Ross -
Changed lines 21-25 from:

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:

<center> <img src="textmate_shell_variables_preferences.png" alt="Textmate Shell Variables Preferences"/> </center>

to:

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.

May 30, 2010, at 23:45 UTC by Alex Ross - How to setup TextMate's PATH.
Added lines 1-34:

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:

<center> <img src="textmate_shell_variables_preferences.png" alt="Textmate Shell Variables Preferences"/> </center>

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
May 30, 2010, at 23:44 UTC by Alex Ross - How to setup TextMate's PATH.