I'm running Mountain Lion 10.8.4, and have my environment all customized through ~/.profile so that when I run GUI apps like Sublime Text or Eclipse from the command line

open /Applications/Sublime\ Text\ 2.app

they inherit my $PATH settings, allowing the app to run external commands not in OSX's very limited default path. However, I'd really like to be able to open programs through Finder or the Dock and give them the same path I use on the command line. launchctl setenv PATH $PATH doesn't work in 10.8. How do I set this up?

up vote 6 down vote accepted


This no longer works with more recent versions of OS X, including 10.10 Yosemite (I'm not sure about 10.9 Mavericks). It does work with 10.8 Mountain Lion, however.

It's actually not too hard, but you do need to have admin privileges (using the sudo command to write to /etc).

  1. From Terminal (or your favorite substitute), see if there's anything in the file /etc/launchd.conf:

    cat /etc/launchd.conf

    If you get an error like

    cat: /etc/launchd.conf: No such file or directory

    then continue with the next step. If the cat command does display some content, copy it.

  2. Determine your system's current path, as we'll need to make sure we include it later:

    launchctl getenv PATH
  3. In your favorite editor, create a new text file with the following content, modified to fit your needs:

    setenv PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/YourUserName/bin:/path/to/gems/bin

    Make sure you've included the entire contents of the path from the previous step, otherwise you'll break your system.

    If the cat command from Step 1 displayed some content, paste it into the new file before the setenv PATH command. If it already contains a setenv PATH command, just modify it to add the extra directories you need.

  4. Save the new file in your home directory (/Users/YourUserName) as launchd.conf.

  5. Go back to Terminal and enter:

    sudo mv ~/launchd.conf /etc

    to use admin power to move the new file to /etc, replacing anything that was there before. Depending on your previous usage of the sudo command, you may get a short "be careful doing what you're doing" message, but either way you'll need to enter your password. /etc is not directly accessible through the Save dialog of graphical editors unless you're a real power user and know how to get around OSX's file system restrictions.

  6. Reboot your computer

And you should be all set. If you're interested, launchd and launchctl use the csh/tcsh syntax, so you can't use the bash/zsh export PATH=/usr/local/bin:... format.

  • It's said this no longer works since OS X Yosemite; see discussion in stackoverflow.com/a/588442/822138 – sam Jan 21 '16 at 21:17
  • @sam I know :( I recently got a new iMac with 10.10 on it, tried the launchd hack, and it didn't work. I'd appreciate any pointers to an updated working method. – MattDMo Jan 21 '16 at 21:22

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.