1 min read

How to persistently set environment variables on OSX 10.10

In OSX Yosemite, for security reasons, Apple disabled the ability to set environment variables from the /etc/launchd.conf file. But never fear, you can still set them with a LaunchAgent.

1. Create a plist file.

$ touch ~/Library/LaunchAgents/environment.plist

2. In that file, place the environment variable you want to set in this format:

Label my.startup ProgramArguments sh -c launchctl setenv FOO bar RunAtLoad

Where “FOO” is the variable to set and “bar” is the value to set it to.

3. Activate the plist file, either by restarting or by executing

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

Reference: [Setting environment variables via launchd.conf no longer works in OS X Yosemite? – Stack Overflow](Setting environment variables via launchd.conf no longer works in OS X Yosemite? – Stack Overflow)

← All posts