I tried all methods I heard of for setting environment variables on OS X 10.8 but none of them seems to work.

To test, run a bash script from inside a gui application like Eclipse or IntelliJ IDEA.

set|grep PATH

Things I tested and that are not working even after reboot:

  • /etc/paths and /etc/paths.d/something
  • /etc/launchd.conf
  • ~/.bash_profile
  • ~/.MacOSX/environment.plist (binary plist made as recommended)
  • running launchctl setenv PATH $PATH from the command line, this was supposed to update the PATH for GUI apps, at least for current session. Guess what, no change.

It seems that PATH is always PATH=/usr/bin:/bin:/usr/sbin:/sbin for GUI apps.

  • Are you OK with a solution that sets the bash path or do you really need to change launchd's value of the base path for all processes?
    – bmike
    Sep 11, 2012 at 15:29
  • I need to change the PATH used by GUI apps, for terminal/bash/... I already have a big set of working solutions.
    – sorin
    Sep 11, 2012 at 15:32
  • I don't know why eclipse and others don't just support runtime environment variables so every java developer on Mac doesn't need to worry about setting the path or sourcing in their desired variables in each project.
    – bmike
    Oct 1, 2012 at 18:34
  • answer see here: apple.stackexchange.com/questions/51677/…
    – Flori
    Jan 24, 2013 at 12:39

4 Answers 4


With Mountain Lion /etc/launchd.conf is where you should set the GUI applications Path. Remember it's not a script file; it only supports launchctl commands so you should write something like:

setenv PATH /new/path:/usr/bin:/bin:/usr/sbin:/sbin

Note also that it doesn't support shell environment variable substitutions (like $PATH) so you'll have to set every path that you want to include. It's a good idea to keep the original paths that you've mentioned (/usr/bin:/bin:/usr/sbin:/sbin).

You'll have to reboot after changing (or creating) the file for the changes to take effect.

  • This worked for me in 10.8.2 for setting a PATH which was usable with Keyboard Maestro.
    – TJ Luoma
    Dec 19, 2012 at 6:12
  • The man page says that you can use $HOME/.launchd.conf but that did not work for me. Using /etc/launchd.conf did. I'm on 10.8.4
    – pedz
    Aug 29, 2013 at 0:00
  • It doesn't work for me : -bash: setenv: command not found
    – Colas
    Oct 9, 2013 at 12:15
  • If anyone was confused like Colas, setenv is a launchctl command, so you use it like launchctl setenv.
    – Jon Shier
    May 14, 2014 at 19:31

It works if you call the GUI app from Terminal:

PATH=/this/is/kind/of/crazy:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin /Applications/Automator.app/Contents/MacOS/Automator 

enter image description here

Not really nice or comfortable but it does the job if needed.

  • Shortly NO WAY. I am not willing to do this, it will work only sometimes. The app can also be started when you click on a file.
    – sorin
    Sep 12, 2012 at 10:37
  • 3
    As I said it's not really nice but may work until Apple fixes the issue (because it should be possible with launchctl).
    – nohillside
    Sep 12, 2012 at 10:49

I cooked up another solution, inspired by patrix one here, that hopefully is a little less painful. Open Automator, select an application as target, and choose Execute Shell script (or whatever it is called, in German it is "Shell-Skript ausführen" as can be seen above) as action. In the script, just type

launchctl setenv FOO1 bar1
launchctl setenv FOOn barn
open -a YourApplicationHere

Then save the whole thing wherever you want, and if you need to run YourApplicationHere, open the created "automator application" instead.

I tested this with Terminal as YourApplicationHere, and saw with launchctl export that FOO was indeed set to bar. I hope it works for others as well.

Finally, if you use this solution for your environment variables, instead of typing the launchctl stuff in the shell script, you may just call /Users/Shared/conflaunchd.sh (which you have to make up first, together with the file describing the variables).


Supposedly, launchctl provides PATH to GUI Apps. To set the path to that of shell path, add the following to your shell rc file after setting your path:

launchctl setenv PATH $PATH
  • 1
    Unfortunately this doesn't work :-(
    – nohillside
    Sep 11, 2012 at 21:45
  • We allow answers that make a good faith effort to address the question. We even allow wrong answers and let the voting speak for correctness. Commenting without making it personal is the best way to poke a hole in a faulty argument rather than discouraging attempts to answer.
    – bmike
    Oct 1, 2012 at 18:22

Not the answer you're looking for? Browse other questions tagged .