1

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
    
  • Please share the output of running type -a vim and echo $PATH in the Terminal. – Nimesh Neema Jun 21 at 11:18
  • Many thanks for your comments @NimeshNeema. I updated the question with the requested outpus – ecjb Jun 21 at 11:31
2

The output of both brew info vim and type -a vim clearly states that Homebrew provided version of vim is not installed on your system.

It appears that you have both ex-vi and mac-vim installed which are conflicting formula for vim. Trying to install vim by running brew install vim while ex-vi and mac-vim are installed results in the following error:

$ brew install vim
Error: Cannot install vim because conflicting formulae are installed.
  ex-vi: because vim and ex-vi both install bin/ex and bin/view

Please `brew unlink ex-vi` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side effects in the
resulting software.

If you wish to use the latest version of vim, you'll need to uninstall ex-vi and mac-vim by running:

brew uninstall ex-vi macvim

Now install vim by running brew install vim. Once the installation is successful, you can confirm the same by running type -a vim, which should output:

vim is /usr/local/bin/vim
vim is /usr/bin/vim

Resolution

The Homebrew installed vim was not linked. To link it requires running:

brew link vim

which gave the following error:

$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.

The error can be resolved by fixing the permission by running:

sudo chown -R `whoami`:admin /usr/local/share/man/de/man1

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 of vim will take precedence over system installed copy.

  • Many thanks for your answer @NimeshNeema. I updated the question: here is what I get from your proposed command: brew uninstall ex-vi macvim: Error: No such keg: /usr/local/Cellar/ex-vi – ecjb Jun 21 at 12:15
  • @ecjb What about brew list? – Nimesh Neema Jun 21 at 12:15
  • I updated the question with the requested output @NimeshNeema – ecjb Jun 21 at 12:20
  • @ecjb From the brew list output it appears that neither ex-vi nor macvim is installed, but vim appears to be installed. Can you try running the following commands one by one and see what happens: brew uninstall vim, brew install ex-vi and brew install macvim? – Nimesh Neema Jun 21 at 12:30
  • I updated the question @NimeshNeema. Thank you very much for your patience! Are the "conflicting files" the issue? – ecjb Jun 21 at 15:14

You must log in to answer this question.

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