Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
see also <…;. It is pretty much a duplicate. – Philipp Kunz Mar 29 at 11:08
up vote 22 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
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
I can only speak for my self, but the described is still working for me on 10.9 - and it also working on the upcoming 10.10 – Rene Larsen Aug 27 '14 at 8:45

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 -

(slightly re-written about the environment variables)

Create an empty text file called "" in the Eclipse application bundle directory /Applications/eclipse/

Open the 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, i.e.:

chmod +x /Applications/eclipse/

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

MacOS X does not automatically detect that the'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/

The next time you launch 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 "" (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/ 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 OS X 10.10 Yosemite, I used this command:

sudo launchctl config user path <my path setting>

Be aware that his sets the launchtl PATH for all users. This worked well for my use case.

share|improve this answer
This doesn't seem to have an effect on the PATH environment variable of applications that are reopened at login (that were open when shutting down). – Brecht Machiels Jul 8 at 14:35

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 or 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
You should find that the Terminal process picks up the PATH value you set, but: when you create a new terminal it starts a login shell, which—if you're using bash—executes /etc/profile, which initializes PATH to the value returned from /usr/libexec/path_helper. If you choose Shell > New Command… and run env (not in a shell) you should find that PATH is the value you set via launchd. – Chris Page Apr 22 at 20:46

Try setting path in your ~/.profile or ~/.bash_profile or ~/.zprofile (for zsh). This worked for me with VimR -- it wasn't reading the PATH when launched from the dock, but it worked when launched from the terminal. I was running on OSX 10.11 by the way.

I don't have a good enough handle on this to give you a great explanation of why it works, there are plenty of explanations online about the different config files and what they do:

Also, see a similar discussion here:

share|improve this answer
The question asks how to do it for apps launched from Doc which is the same as launch from Finder which you say your answer does not work for - and we can exactly explain why it does/does not work – Mark Oct 22 '15 at 23:02

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.