How to set PATH for Finder-launched applications

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?


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

On OS X 10.10 Yosemite, I used this command:

sudo launchctl config user path <my path setting>

Be aware that his sets the launchtl PATH for all users. This worked well for my use case. Note that you'll be asked to reboot your machine for the effects to take hold.

You must restart all applications for this to have effect. (It doesn't apply to applications that are reopened at login after rebooting.) (Thanks @Brecht Machiels.)