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

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:

<pre class="src src-sh">defaults write ${<span style="color: #eedd82;">HOME</span>}/.MacOSX/environment PATH <span style="color: #ffa07a;">"${PATH}"</span>

then restart (log out) computer to take effect.

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

<pre class="src src-sh"><span style="color: #00ffff;">if</span> [ -x /usr/libexec/path_helper ]; <span style="color: #00ffff;">then</span>

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

 <pre class="src src-sh">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.

About Vinh Nguyen



  1. Pingback: teaules

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>