Super User is a question and answer site for computer enthusiasts and power users. 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

I'm using MacVim and when I don't launch it from the Terminal (mvim) its $PATH does not include what I have set in my .bash_profile. It only seems to have the default values, /usr/bin:/bin:/usr/sbin:/sbin.

I'm running OS X 10.5.8. Even if I could set it manually in my .vimrc that would be okay, though I would prefer it to pull from the same place as Terminal. I've tried following what one site suggested, adding let $PATH += /blah/foo:/bar/etc to no avail.

Edit/Solution: See my answer below. MacVim has an option to fix this.

share|improve this question
up vote 11 down vote accepted

MacVim appears to be getting the $PATH in a way that ignores a regular user's custom dotfiles.

I can't say why they prefer to do it this way, but it appears to be true. In the preferences (under the Advanced tab), you can choose to "Launch Vim processes in a login shell", but it only improves the $PATH slightly for me.

The best I can tell, MacVim uses /usr/libexec/path_helper - which in turn uses the items found (1) in the /etc/paths file and (2) anything additional found in the /etc/paths.d/ directory. Any changes made in a user's home directory (via .profile or the like) is ignored.

In a nutshell, you get the OSX defaults, plus any applications that add themselves to /etc/paths.d. (For example, MacTex does so on my system.) So if you want to adjust your MacVim path, one way would be to add a file with items to /etc/paths.d. (I wouldn't directly edit /etc/paths since then you run the risk of the changes being undone by system updates.)

Thanks for letting me know this. I'm off to file a wishlist bug at MacVim.

share|improve this answer
I would have thought that as well, but I have added a few things '/etc/paths.d/' which show up in Terminal but not with MacVim. – donut Sep 27 '09 at 5:37
And actually, there's more in my '/etc/paths' file than what's in MacVim's path. – donut Sep 27 '09 at 5:47
@Donut: well, that is odd. On my machine, if I add something to /etc/paths.d, it shows up the next time I boot MacVim. What format are you putting in there? It should be one item per line, I believe, with a $PATH directory on each line (e.g., /usr/texbin). – Telemachus Sep 27 '09 at 11:17
I totally missed your first paragraph originally: Choosing to "Launch Vim processes in a login shell" did the trick for me. See my answer. – donut Feb 3 '10 at 9:55

BTW, the "Launch Vim processes in a login shell" preference is no longer available in MacVim (at least not v7.3). I see that launching MacVim from the Finder gets the wrong path, but launching it from a shell (as "mvim") gets the correct path.

share|improve this answer

It's not sourced from .bash_profile, but you can use this in your .vimrc:

let $PATH=$PATH . ':/blah/foo'

You have to have the : or it won't be a correct PATH variable.

share|improve this answer
I just tried it, and this doesn't seem to change the $PATH for MacVim. I also tested it with Vim in the Terminal (both /usr/bin/vim (from Apple) and /opt/local/bin/vim (from MacPorts), and it seems unnecessary. Vim in the terminal already picks up the proper $PATH as sourced by my dot files. – Telemachus Sep 26 '09 at 12:18
I tried this as well to no avail. – donut Sep 27 '09 at 10:10

I can't believe I didn't see this before. Okay, I can believe it. Anyways, MacVim comes with an option that solves this. Under Preferences just check "Launch Vim processes in a login shell". That's it, it works. Snazzy. Stupid me.


I accidentally wrote this answer not realizing that Telemachus had already given me the correct answer. Marked his as the answer.

share|improve this answer
Glad it's sorted – Telemachus Feb 14 '10 at 15:30

This Mac Dev Center article may be of some use.

share|improve this answer
Can't get it to work. Could be doing something wrong. The article suggests adding the 'LSEnvironment' property in an app's 'information property list file' which I assumed to be ~/Library/Preferences/org.vim.MacVim.plist. I made it a dictionary with 'PATH' (also tried 'path' and '$PATH') as the a key and what I want for the path as a string value. Still seems to be pulling PATH from some mysterious source. Screenshot of the plist file – donut Sep 5 '09 at 9:42

I had no problem adding a file to the paths.d directory. I added a file called mysql, whose contents were:


Then I placed this file under the paths.d directory, and changed its ownership to root:wheel. Now the mysql directory is automatically added to my $PATH variable.

I didn't investigate fully, but possibly (a) including the [RETURN] at the end of the line, and/or (b) setting the file ownership to root, might be necessary.

share|improve this answer

I know more about unix than about macs, so the following advice may or may not work. Try putting this your .vimrc file:

! source ~/.bash_profile

That might do the trick, but there's a slight caveat: the .bash_profile is only meant to be sourced once. It may contain some non-idempotent commands (things which should only execute once). Case in point:

$PATH += /blah/foo:/bar/etc

The more that gets called, the bigger and more redundant $PATH gets. However, if that's not such a big deal, the recommendation on unix would be to put the one-time command in ~/.bashrc and run source ~/.bashrc from your .vimrc file.

share|improve this answer
Neither sourcing .bash_profile or .bashrc worked. I tried manually running :source .bash_profile but it just comes up with a "Not an editor command" error for every command in the file and the same with .bashrc. – donut Aug 29 '09 at 1:58
sorry...what was I might try ! source .bash_profile – David Berger Aug 29 '09 at 15:05
Tried both .bash_profile and .bashrc but still no go. Here's what I'm using in my .bash_profile to change PATH: 'PATH=/usr/local/bin:/Applications/‌​pplications/MacVim/:$PATH' And in my .bashrc: 'export PATH=/Applications/MAMP/bin/php5/bin:$PATH'. And it's .bash_profile that actually affects my Terminal sessions. – donut Aug 30 '09 at 13:57

MacVim will source ~/.zprofile and /etc/profile, so you can put your PATH settings in there.

See and this question on Stack Overflow.

(Tested with MacVim version 7.3 (65)).

share|improve this answer

You must log in to answer this question.

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