I'm seeing something very odd, and honestly I'm stumped.
The version of vim that comes with mac is outdated (7.3 instead of 7.4). I'm trying to install vim from homebrew, and I want to use that one instead of the default apple version.
I ran "brew install vim
". It installed correctly in /usr/local/bin/vim
. All good.
When I run "which vim
", it prints "/usr/local/bin/vim
". The Apple version of vim is installed at /usr/bin/vim
. So the which command is telling me that I'm using the homebrew version of vim.
However, when I actually run vim, it still runs the Apple version
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 9 2015 23:58:42)
Compiled by [email protected]
...
If I run the homebrew version explicitly, I see this:
$ /usr/local/bin/vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 23 2015 18:16:35)
MacOS X (unix) version
Included patches: 1-898
Compiled by Homebrew
...
I even tried moving /usr/bin/vim
to /usr/bin/vim73
to try to force using the homebrew version. However, when I did this, here is what I see when I try to run vim:
$ vim --version
-bash: /usr/bin/vim: No such file or directory
$
What is going on? How can I get it to run the homebrew version of vim?
Start a new shell session and it’ll work.
Bash caches executables’ paths so when you run vim
it looks at your PATH
to find the first executable with this name. It caches it and the second time you run vim
it remembers vim
is actually /usr/bin/vim
and runs that.
Since you haven’t restarted your Bash session its cache is still the same; hence the error you’re seeing. It has nothing to do with the way you installed vim
.
If you don’t want to start a new shell session, you can run hash -r
to tell Bash to clear its executables memory.