Last weekend I upgraded my Mac to OS X Mountain Lion. Everything went pretty smoothly. I had to re-install Java, but that happened automatically when I first tried to run it. I also had to re-install Xcode, but the App Store made that pretty painless.
But when I ran a build from inside Xcode it failed because it couldn’t find
coffee. Right. Because Xcode doesn’t have access to the
PATH set in my shell.
The previous recommendation for setting your
PATH for all apps, including GUI ones, on Mac OS X has been to use
~/.MacOSX/environment.plist. With Mountain Lion, that’s stopped working. Nice.
After a bit of googling, and a couple of restarts (really? I thought we were supposed to be living in the future?) I got this fixed.
For environment variables to be available to all apps, they need to be set by
This file is a list of
launchctlcommands; it is not a shell script. Therefore, it doesn’t have any shell environment variable substitution.
To set an environment variable use something like:
setenv VAR "custom value"
But this will overwrite any existing value, so if you just want to add something to the
PATHyou’ll need to include the original value.
I wanted to add
/usr/local/bin, so the following worked:
setenv PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
/usr/bin/:/bin:/usr/sbin:/sbinis the entirety of the default Mac OS X
/etc/launchd.conffile is only read at startup, so you’ll need to restart for changes to take affect.
Hope that helps. Interesting fact: if you accidentally clear your
PATH your Mac will pretty much still work. Except the screensaver won’t start.