Setting PATH in MacOS – Configuring Environmental Variable for Finder-Launch Applications

findermacospath

Apps launched via Finder seem to not respect the PATH as set in .bash_profile. So when I try to run code from an IDE (Intellij) I no longer have access to programs in /usr/local/bin, which is normally added to my path in the Terminal.

Apparently .MacOSX/environment.plist used to be the way to do this, but it no longer works in Lion.

How can I set the PATH for Finder-launched applications?

Best Answer

If you are on 10.7 and not 10.8, the solution below works well:

I had the same problem with eclipse, but now I've added e.g. the following to my .bash_profile and then it worked.

export PATH=some_path:another_path
launchctl setenv PATH $PATH

In case you want to leave the original path intact use

p=$(launchctl getenv PATH)
launchctl setenv PATH /my/new/path:$p

instead (or just launchctl setenv PATH /my/new/path:$(launchctl getenv PATH)).

Note: Changing the launchctl PATH will not take effect until the Dock is "restarted". A new Dock process will automatically start after the current one is killed with the command:

killall Dock