global environment variables (like PATH) in mac os x via environment.plist and /etc/launchd.conf

Emacs
Mac OS X
Author

Vinh Nguyen

Published

August 13, 2009

so, through my journey of getting emacs 23 and conkeror to work on mac os x, i've discovered that PATH is not defined for native mac gui apps. details of the journey can be found in this post of mine's.

now, to sum it up, to get PATH or other env variables working in mac gui apps, you need to create or modify your ~/.MacOSX/environment.plist file. i usually define my PATH in .bashrc, so i do something like

In terminal, type:

defaults write ${HOME}/.MacOSX/environment PATH "${PATH}"

then restart (log out) computer to take effect.

To update the path of environment.plist at every login, do (credit here):

if [ -x /usr/libexec/path_helper ]; then
 eval `/usr/libexec/path_helper -s`
 defaults write $HOME/.MacOSX/environment PATH "$PATH"
fi

in /etc/profile

logout and log back in. however, apps launched using spotlight still do not see the env vars. they are seen only when launched using Finder. so, to fix that, put something like

setenv PATH /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin:/Users/vinh/Documents/bin/:/opt/local/bin:/opt/local/sbin:/usr/texbin

in your /etc/launchd.conf file. a restart is required. this second method works for all apps start in mac.

these files should be edited each time u add to your PATH in .bashrc.

see my original post to follow all the credit.