I have troubling merging several version of vim
on my machine. I have successfully installed vim
via Homebrew. Here's the output of running brew info vim
:
vim: stable 8.1.1550 (bottled), HEAD
Vi 'workalike' with many additional features
https://www.vim.org/
Conflicts with:
ex-vi (because vim and ex-vi both install bin/ex and bin/view)
macvim (because vim and macvim both install vi* binaries)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/vim.rb
==> Dependencies
Required: gettext ✔, lua ✔, perl ✔, python ✔, ruby ✔
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 89,945 (30 days), 222,053 (90 days), 835,730 (365 days)
install_on_request: 82,933 (30 days), 204,131 (90 days), 747,520 (365 days)
build_error: 0 (30 days)
However when typing vim --version
, I get:
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 22 2019 19:03:04)
Included patches: 1-503, 505-680, 682-1283
Compiled by root@apple.com
It seems that there are 2 versions installed on my machine and the the one installed with Homebrew is not the default one. How can I make it the default one?
Here the output of running various commands for debugging:
-
type -a vim
:vim is /usr/bin/
-
echo $PATH
:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
-
brew uninstall ex-vi macvim
:Error: No such keg: /usr/local/Cellar/ex-vi
-
brew list
:aom leptonica perl arpack libass pixman autoconf libbluray pkg-config cairo libcerf plotutils cmake libde265 portaudio eigen libevent pstoedit epstool libffi pyenv ffmpeg libheif pyenv-virtualenv fftw libmpc pyqt fig2dev libogg python flac libomp python@2 fltk libpng qhull fontconfig libsamplerate qrupdate freetype libsndfile qt frei0r libsoxr readline fribidi libtasn1 rtmpdump gcc libtiff rubberband gd libtool ruby gdbm libunistring sdl2 gettext libvorbis shared-mime-info gflags libvpx sip ghostscript libxml2 snappy giflib libyaml speex gl2ps little-cms2 sphinx-doc glib lua sqlite glog metis suite-sparse glpk mpfr sundials gmp netpbm szip gnuplot nettle tbb gnutls node tesseract graphicsmagick numpy texinfo graphite2 octave theora harfbuzz open-mpi unbound hdf5 openblas veclibfort icu4c opencore-amr vim ilmbase opencv webp imagemagick openexr wfdb ipython openjpeg x264 isl openssl x265 jasper opus xvid jpeg p11-kit xz jupyter pandoc zeromq lame pango latex2rtf pcre
-
brew uninstall vim
:Uninstalling /usr/local/Cellar/vim/8.1.1550... (1,855 files, 31.6MB)
-
brew install ex-vi
:Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae antibody cxxopts k3d k6 yapf ==> Updated Formulae ansible hadolint jhipster ==> Downloading https://homebrew.bintray.com/bottles/ex-vi-050325.mojave.bottle.tar.g ######################################################################## 100.0% ==> Pouring ex-vi-050325.mojave.bottle.tar.gz ? /usr/local/Cellar/ex-vi/050325: 18 files, 348.2KB
-
brew install macvim
:==> Installing dependencies for macvim: cscope ==> Installing macvim dependency: cscope ==> Downloading https://homebrew.bintray.com/bottles/cscope-15.9.mojave.bottle.tar.gz ######################################################################## 100.0% ==> Pouring cscope-15.9.mojave.bottle.tar.gz ? /usr/local/Cellar/cscope/15.9: 11 files, 711.6KB ==> Installing macvim ==> Downloading https://homebrew.bintray.com/bottles/macvim-8.1-156.mojave.bottle.tar ==> Downloading from https://akamai.bintray.com/0a/0ae9784f9fb5afc98628250e542b8d1289 ######################################################################## 100.0% ==> Pouring macvim-8.1-156.mojave.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/vi Target /usr/local/bin/vi is a symlink belonging to ex-vi. You can unlink it: brew unlink ex-vi To force the link and overwrite all conflicting files: brew link --overwrite macvim To list all files that would be deleted: brew link --overwrite --dry-run macvim Possible conflicting files are: /usr/local/bin/vi -> /usr/local/Cellar/ex-vi/050325/bin/vi /usr/local/bin/view -> /usr/local/Cellar/ex-vi/050325/bin/view ==> Summary ? /usr/local/Cellar/macvim/8.1-156: 2,214 files,
-
brew uninstall ex-vi
:Uninstalling /usr/local/Cellar/ex-vi/050325... (18 files, 348.2KB) You have new mail in /var/mail/mymac
-
brew uninstall macvim
:Uninstalling /usr/local/Cellar/macvim/8.1-156... (2,214 files, 35.9MB)
-
brew install vim
:
Updating Homebrew…
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.==> Downloading https://homebrew.bintray.com/bottles/vim-8.1.1550.mojave.bottle. Already downloaded: /Users/mymac/Library/Caches/Homebrew/downloads/06a6b020860987044c9b8081af3a27b1968e648ce496338bd99a572a656c148a--vim-8.1.1550.mojave.bottle.tar.gz ==> Pouring vim-8.1.1550.mojave.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/man/de/man1/ex.1 /usr/local/share/man/de/man1 is not writable. You can try again using: brew link vim ==> Summary ? /usr/local/Cellar/vim/8.1.1550: 1,855 files, 31.6MB
-
brew link vim
:Linking /usr/local/Cellar/vim/8.1.1550... Error: Could not symlink share/man/de/man1/ex.1 /usr/local/share/man/de/man1 is not writable.
However, after those steps, I still get which tells me that VIM didn't get updated:
-
vim --version
:VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 22 2019 19:03:04) Included patches: 1-503, 505-680, 682-1283 Compiled by root@apple.com
Best Answer
The output of both
brew info vim
andtype -a vim
clearly states that Homebrew provided version of vim is not installed on your system.It appears that you have both
ex-vi
andmac-vim
installed which are conflicting formula forvim
. Trying to installvim
by runningbrew install vim
whileex-vi
andmac-vim
are installed results in the following error:If you wish to use the latest version of
vim
, you'll need to uninstallex-vi
andmac-vim
by running:brew uninstall ex-vi macvim
Now install
vim
by runningbrew install vim
. Once the installation is successful, you can confirm the same by runningtype -a vim
, which should output:Resolution
The Homebrew installed
vim
was not linked. To link it requires running:brew link vim
which gave the following error:
The error can be resolved by fixing the permission by running:
Followed by finally attempting the link again by running:
brew link vim
This will link to Homebrew installed
vim
binaries under/usr/local/bin
and thus Hombrew installed copy ofvim
will take precedence over system installed copy.