HowTo: Set an Environment Variable in Mac OS X
There are a number of ways of setting environment variables in Mac OS X. We will show the different approaches and talk about the advantages and disadvantages of each.
- With the Terminal Only approach, you can set system wide and user specific environment variables, however it can only be used in the Terminal.
- With
~/.MacOSX/environment.plist
all programs can use these environment variables, but can only set user specific environment variables, and a log out and back in is required. Not supported in Mac OS X 10.8 and later. - With
/etc/launchd.conf
all programs can use these environment variables, but can only set system wide environment variables, and a reboot is required. Not supported in Mac OS X 10.10 and later. - With launchd.plist, the same things can be accomplished as with
/etc/launchd.conf
but formatted in an XML document.
Parts of this series
- HowTo: Set an Environment Variable in Mac OS X
- HowTo: Set an Environment Variable in Mac OS X - Prerequisites
- HowTo: Set an Environment Variable in Mac OS X - Terminal Only
- HowTo: Set an Environment Variable in Mac OS X - $HOME/.MacOSX/environment.plist
- HowTo: Set an Environment Variable in Mac OS X - /etc/launchd.conf
- HowTo: Set an Environment Variable in Mac OS X - launchd.plist