Macos – Accessing the Unix environment from emacs and Cocoa apps in OS X Mountain Lion


I use emacs on my mac, I install the Cocoa version of emacs using homebrew.
One problem is that in order to see the "Unix path" I had to replicate my path from .profile to .MacOSX/environment.plist

I do it with this in my .profile:

# PATH for emacs and cocoa apps
/etc/profile begin
if [ -x /usr/libexec/path_helper ]; then
  eval `/usr/libexec/path_helper -s`
  defaults write $HOME/.MacOSX/environment PATH "$PATH"

And that used to work, but it stopped working when I installed Mountain Lion. I can't find any manual that says that they've changed it on this version.

Does anyone know how to see the unix path from cocoa applications on Mountain Lion?

Best Answer

  • To formally answer this question: It could be that .MacOSX/environment.plist does not work anymore (?) or at least not reliably. It never worked for apps launched by Spotlight. It is documented though: Runtime Configuration Guidelines: Environment Variables

    The alternative to that is using launchctl, which will make environment variables accessible to GUI apps. For example, this copies your shell's PATH to the environment:

    launchctl setenv PATH $PATH

    For any changes to $PATH, you will have to restart the affected apps. You do not need to reboot if you use above syntax. If, however, you change /etc/launchd.conf, you will need to reboot. See also: Setting environment variables in OS X? - Stack Overflow