Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Apps launched via Finder seem to not respect the PATH as set in .bash_profile. So when I try to run code from an IDE (Intellij) I no longer have access to programs in /usr/local/bin, which is normally added to my path in the Terminal.

Apparently .MacOSX/environment.plist used to be the way to do this, but it no longer works in Lion.

How can I set the PATH for Finder-launched applications?

share|improve this question
Are you sure that your accepted solution works on 10.8? –  sorin Sep 11 '12 at 14:40
@SorinSbarnea (I know this is old, but) I can verify that the currently-accepted answer works for me on OS X 10.8.3, when I also use the suggested dock restart hack. (I'm setting a different environment variable though, not $PATH in case that matters.) –  Calrion May 24 '13 at 6:28

5 Answers 5

up vote 13 down vote accepted

If you are on 10.7 and not 10.8, the solution below works well:

I had the same problem with eclipse, but now I've added e.g. the following to my .bash_profile and then it worked.

export PATH=some_path:another_path
launchctl setenv PATH $PATH

In case you want to leave the original path intact use

p=$(launchctl getenv PATH)
launchctl setenv PATH /my/new/path:$p

instead (or just launchctl setenv PATH /my/new/path:$(launchctl getenv PATH)).

Note: Changing the launchctl PATH will not have an effect until you restart the dock:

osascript -e 'tell app "Dock" to quit'
share|improve this answer
I ended up using: "launchctl setenv PATH $PATH". Appending the existing launchctl path via "$p" ends up repeating the path each time you open a shell. –  Caffeine Coma May 20 '12 at 13:06
Also worth noting- until you have started up a shell (via Terminal) launchctl will have the default path, and the customized path will not be available. This drove me a little batty trying to debug things until I figured out what was going on. If I started Intellij before opening a shell, the path would be wrong. Seems like the real solution here is to configure launchctl on a system-wide basis, and not via login shell by some user. –  Caffeine Coma May 20 '12 at 13:16
This does not work on OS X 10.8 - tried with Eclipse and IntelliJ - running set|grep PATH from them will always return PATH=/usr/bin:/bin:/usr/sbin:/sbin –  sorin Sep 11 '12 at 14:39
Doesn't work for my either (10.8.1) –  patrix Sep 12 '12 at 4:42
You might try restarting the dock after running launchctl: osascript -e 'tell app "Dock" to quit'. That seemed to fix it for me. –  Ivan Andrus Nov 7 '12 at 16:44

To answer you question to your 'new' problem, I've decided to write another answer - because it is easier to explain with samples.

One way to load the environment variables on startup of your tool (IDE) of choice is like it can be done with eclipse - I think there must be a similar structure in your tool (IDE) too.

How it can be done in eclipse - http://stackoverflow.com/questions/829749/launch-mac-eclipse-with-environment-variables-set

(slightly re-written about the environment variables)

Create an empty text file called "eclipse.sh" in the Eclipse application bundle directory /Applications/eclipse/Eclipse.app/Contents/MacOS

Open the eclipse.sh in a text editor and enter the following contents:


. ~/.bash_profile

logger "`dirname \"$0\"`/eclipse"

exec "`dirname \"$0\"`/eclipse" $@

In the Terminal set the executable flag of the shell script eclipse.sh, i.e.:

chmod +x /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.sh

Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh.

MacOS X does not automatically detect that the Eclipse.app's Info.plist has changed. Therefore you need to force update the LaunchService database in the Terminal by using the lsregister command:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app

The next time you launch Eclipse.app from the Dock or from the Finder the environment variables should be set.

share|improve this answer
This technique also works for Rubymine once you adjust the path. I found it didn't at first, but then realised that my settings were in .profile, not .bash_profile. –  Matt Gibson Nov 16 '12 at 13:29
+5000 for the lsregister reference. –  Laird Nelson Oct 17 '14 at 21:37

On Mountain Lion all the /etc/paths and /etc/launchd.conf editing doesn't take any effect!

Apple's Developer Forums say:

"Change the Info.plist of the .app itself to contain an "LSEnvironment" dictionary with the environment variables you want.

~/.MacOSX/environment.plist is no longer supported."

So I directly edited the app's Info.plist (right click on "AppName.app" (in this case SourceTree) and then "Show package contents")

Show Package Contents

and added a new key/dict pair called:


(see: LaunchServicesKeys Documentation at Apple)

enter image description here

now the App (in my case SourceTree) uses the given path and works with git 1.9.3 :-)

PS: Of course you have to adjust the Path entry to your specific path needs.

share|improve this answer
Is this true? I see lots of posts with contradictory information, some of which are clearly old, but some of which seems recent. I don't even have (on 10.8.2) a /etc/launchd.conf anyway. Presumably, even if the rules not state that apps should use their Info.plist files for paths, they could still be using other files -- /etc/launchd.conf, /etc/paths/, or /etc/paths.d/*, or `~/.MacOSX/environment.plist. Is it safe to say then that, in practice, paths for GUI apps in Mountain Lion could be set in any of these files? –  raxacoricofallapatorius Feb 3 '13 at 17:47
This Info.plist was the only thing what worked for me, after trying lauchd.conf, etc/paths etc with my Maverics and eclipse. Actually this did not work immediately also, you need to remember two things: 1. run /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fra‌​mework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app as given in another answer, after changing plist and 2. add full path there, you cannot use existing PATH as in your profile scripts. –  JaakL May 5 '14 at 20:30

On Mountain Lion (10.8.4), $PATH is treated specially somehow. launchctl setenv PATH /your/path:/here does not have any effect on the $PATH in Terminal.app or Emacs.app instances subsequently launched from the Dock or from the Finder (whereas launchctl setenv SPONG foo works fine). Also $HOME/.launchd.conf doesn't work. /etc/launchd.conf is the only way I have found to get PATH set correctly everywhere. Unfortunately, one cannot use envars such as $HOME there, so all the users on my laptop have /Users/nb/bin on their $PATH. That's only me, so I don't care.

share|improve this answer

On Mac OS X 10.8.4, Mountain Lion, the path environment incorporates the paths listed in this file:


You can edit this file using a command line tool, such as vim using the following command:

sudo vim /etc/paths
share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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