Setting global environment variables on OS X

Applications (like 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 environment.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" "">
<plist version="1.0">
<string>launchctl setenv RV_OS_PATH_OSX /volumes/zdisk launchctl setenv RV_OS_PATH_WINDOWS Z:</string>


To activate the environment.plist (assuming you named it environment.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

For further reference, see this StackExchange article which talks about setting environment variables in previous versions of OS X up through 10.10 (which still works as of 10.12 Sierra).



  • 0

    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
    Seth Rosenthal

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



  • 0

    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.

  • 0
    (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!


  • 0
    Chris Burgess

    Hi all,

    I'm a bit late to the party here, and knowing Apple this will probably change again next OS, but currently the only always-working-for-sure way to get environment variables to show up in Finder-launched, Terminal-launched, and Spotlight-launched applications (as of High Sierra, OS 10.13) that I know of, is to set a launchctl script as a login item:

    Wonky af, I know, but this is the only thing that has worked for me in all scenarios. I have no idea why Apple insists on making their OS less user-friendly with each iteration, but this is currently working. I took a long time reading tons of forums and trying all the other methods before figuring this out. Hope it can save someone else the headache!

    -Chris Burgess

Please sign in to leave a comment.