15 votes

Faire en sorte que Vim installé par Homebrew remplace celui installé par le système

J'ai du mal à fusionner plusieurs versions de vim sur ma machine. J'ai installé avec succès vim via Homebrew. Voici le résultat de l'exécution 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)

Cependant, lorsque vous tapez vim --version j'obtiens :

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

Il semble qu'il y ait 2 versions installées sur ma machine et que celle installée avec Homebrew ne soit pas la version par défaut. Comment puis-je en faire la version par défaut ?

Voici le résultat de l'exécution de diverses commandes pour le débogage :

  • 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 : Mise à jour de Homebrew... ==> Mise à jour automatique du Homebrew ! Mise à jour de 1 robinet (homebrew/cask). Aucun changement dans les formules.

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

Cependant, après ces étapes, j'obtiens toujours ce qui me dit que VIM n'a pas été mis à jour :

  • 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

13voto

Nimesh Neema Points 44385

La sortie des deux brew info vim y type -a vim indique clairement que la version de vim fournie par Homebrew n'est pas installée sur votre système.

Il semble que vous ayez à la fois ex-vi y mac-vim installés qui sont des formules contradictoires pour vim . Essayer d'installer vim en courant brew install vim tandis que ex-vi y mac-vim sont installés donne lieu à l'erreur suivante :

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

Si vous souhaitez utiliser la dernière version de vim vous devrez désinstaller ex-vi y mac-vim en courant :

brew uninstall ex-vi macvim

Maintenant, installez vim en courant brew install vim . Une fois que l'installation est réussie, vous pouvez la confirmer en exécutant type -a vim qui devrait donner un résultat :

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

Résolution

Le Homebrew installé vim n'était pas lié. Pour le lier, il faut courir :

brew link vim

qui a donné l'erreur suivante :

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

L'erreur peut être résolue en réparant la permission en exécutant :

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

Suivi par une nouvelle tentative de lien en exécutant :

brew link vim

Cela va créer un lien vers Homebrew installé vim binaires sous /usr/local/bin et donc Hombrew a installé une copie de vim aura la priorité sur la copie installée par le système.

12voto

Nicola Leoni Points 146

J'étais confronté au même problème, j'ai essayé la solution proposée par @Nimesh Neema mais la version de vim montrait toujours une version plus ancienne. Apparemment, le redémarrage du shell a réglé le problème :

exec -l $SHELL

Avant : VIM - Vi IMproved 8.0 (2016 Sep 12, compilé Jun 19 2019 19:08:44) Après : VIM - Vi IMproved 8.2 (2019 déc 12, compilé le 29 fév 2020 01:58:02)

LesApples.com

LesApples est une communauté de Apple où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres utilisateurs d'appareils Apple, poser vos propres questions ou résoudre celles des autres.

Powered by:

X