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:
- No: Setting
PATH
in shell start up scripts (e.g. .bashrc
) works only for apps launched by shells.
- No: Setting
PATH
for the current launchd
process via launchctl setenv PATH <...>
does not work for me at all.
- Yes: Setting
PATH
in /etc/launchd.conf
(and restarting the system) will make the appropriate PATH
visible in applications launched by Spotlight, Dock and Finder and subsequently (local) shells.
- No: Remotely invoked shells do not inherit the environment. (See ...why do remote shells via ssh do NOT inherit the environment..)
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 in PATH
.**
To accommodate remote shells you need to re-import the launchd
environment into the shell. Use something like this in your .bashrc
:
# the vexatious path stuff
eval $(launchctl export)
Unfortunate consequences of the whole issue are:
- No way to have these unified settings on a per user basis. (
~/.launchd.conf
does not work.)
- No easy way to construct the PATH from different sources using techniques like home directory expansion et al.