Setting the system-wide PATH environment variable in Mavericks

Yosemite

/etc/launchd.conf is no longer supported in 10.10. See man launchctl:

The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations.

You can now for example save this plist as ~/Library/LaunchAgents/my.startup.plist:

<?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 PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

The launchctl setenv command is ran as the user, so it only applies to processes launched in the user domain.

This method doesn't apply to applications that are reopened at login if "Reopen windows when logging back in" is checked.

Mavericks and earlier

In 10.9 and earlier, you can for example run

echo setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin|sudo tee -a /etc/launchd.conf

and then restart to apply the changes.

Other methods

/etc/paths and /etc/paths.d/ apply only (or mainly) to shells. The lines in /etc/paths and /etc/paths.d/* are added to the path by path_helper, which is run from /etc/profile, /etc/zshenv, and /etc/csh.login. I don't know any programs other than shells that would consider /etc/paths or /etc/paths.d/.

~/.MacOSX/environment.plist stopped working in 10.8.


There is a much easier way. Place a text file in the folder /etc/paths.d/. In this text file, enter the desired path AND a newline. The best way is to create a new file for each path.

On my system, there is a file called MySQL with the text '/usr/local/mysql/bin' and a newline.