On Ask Different there are many questions regarding the PATH
environment variable and how to set it for applications launched by a shell, by spotlight or via the finder (typical questions: How to set PATH for Finder-launched applications or How to change PATH environment variable…).
Answers range from sh
startup scripts to /etc/paths
to /etc/launchd.conf
. Here I am after the answer for a unified setting of PATH
for all apps under Mac OS X Mountain Lion 10.8.2.
Best Answer
After many trials with different options I conclude:
Is there a unified way to set the
PATH
for applications launched by different means (like shell script, Finder and Spotlight)? Well, yes and no:PATH
in shell start up scripts (e.g..bashrc
) works only for apps launched by shells.PATH
for the currentlaunchd
process vialaunchctl setenv PATH <...>
does not work for me at all.PATH
in/etc/launchd.conf
(and restarting the system) will make the appropriatePATH
visible in applications launched by Spotlight, Dock and Finder and subsequently (local) shells.Notes for set-up of shells:
For correct functioning in local shells it is important to switch off the use of
/usr/libexec/path_helper
, because the default paths in/etc/paths
might change the order of the paths inPATH
.**To accommodate remote shells you need to re-import the
launchd
environment into the shell. Use something like this in your.bashrc
:Unfortunate consequences of the whole issue are:
~/.launchd.conf
does not work.)