Setting global environment variables on OS X

RV can make use of environment variables in various ways. It is a bit of a mystery for many Mac users how to create environment variables that will be available for all applications, including those launched from icons, etc. If you are using Windows, please see Setting Global Environment Variables on Windows.

The process involves creating (or editing, if it exists) a special .plist file in the users home directory. You can add the environment variable and it's value here. Then you have to log out and in.

Create the plist file under ~/Library/LaunchAgents/:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>my.startup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>launchctl setenv RV_OS_PATH_OSX /volumes/zdisk launchctl setenv RV_OS_PATH_WINDOWS Z:</string>

</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

To activate the plist, run

launchctl load ~/Library/LaunchAgents/environment.plist
launchctl start ~/Library/LaunchAgents/environment.plist

If it is already loaded and you have modified the plist file, see your updates by running:

launchctl stop ~/Library/LaunchAgents/environment.plist
launchctl unload ~/Library/LaunchAgents/environment.plist
launchctl load ~/Library/LaunchAgents/environment.plist
launchctl start ~/Library/LaunchAgents/environment.plist
Follow

4 Comments

  • 0
    Avatar
    Jo

    for a complet eidiot like me, it would be usefull to mention that from the Apple Article:

    You will have to create the .MacOSX directory yourself using terminal (by typing  mkdir .MacOSX ).

    You will also have to create the environment file yourself...  this is then your touch...  line

    cheers Jo

  • 0
    Avatar
    Seth Rosenthal

    Thanks Jo. I've edited the post to make that part clear.

    Cheers,

    Seth

  • 0
    Avatar
    Brian

    Seems like Apple's gone and changed this again.  I'm having all kinds of issues getting global environment variables to work in Mountain Lion.  I can get RV_SUPPORT_PATH to work, but nothing else.  Any thoughts?

    Here's some info on what Apple has done.  Looks like they think it should be part of the .app package, which kinda kills the idea of an environment variable.

    http://apple.stackexchange.com/questions/57385/where-are-system-environment-variables-set-in-mountain-lion

  • 0
    Avatar
    Michael Kessler

    Hi Brian,

    We've made sure to update this page with the current OSX environment Launch Agent method.

    Thanks for pointing this out!

    -Kessler

Please sign in to leave a comment.