32

I recently upgraded my Mac to High Sierra

After the upgrade, Macvim (mvim) stopped working because (I assume) HighSierra upgraded ruby to 2.3, and mvim is using ruby 2.0.

Following is the error I am getting

dyld: Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib

Referenced from: /usr/local/Cellar/macvim/8.0-134/MacVim.app/Contents/bin/../MacOS/Vim

Do I need to compile vim again or is there any way to fix this problem?

Thanks in advance.

Fatemeh Abdollahei
  • 3,040
  • 1
  • 20
  • 25
user2960993
  • 711
  • 2
  • 8
  • 11

6 Answers6

32

This worked for me. YMMV brew uninstall --purge macvim brew install macvim

[amended] Regarding the upgrade alone option, that may work if you don't have the current version already. The --purge forces a removal and complete reinstall. Also, the build from source option, while it may work, you now own your own mac-vim static snapshot and need to maintain it manually as the app evolves. I'd avoid building from source unless you have very specific needs.

Bruce Edge
  • 1,975
  • 1
  • 23
  • 31
  • Did the trick for me as well. Updating from GUI as suggested in other post did not work for me. Thanks, Bruce! – bduhbya Nov 16 '17 at 21:02
  • 1
    Yep, this one helped me as well! But, I should add that I also had to run GUI Xcode app itself at least once before installing vim, since it needed to install some additional components. See: https://github.com/macvim-dev/macvim/issues/546 – smileart Nov 22 '17 at 16:36
  • 3
    This works for `vim` too, if one insn't using `macvim`. – Chris Townsend Feb 01 '18 at 22:03
  • 5
    In the entire history of the git source for `brew` I can't find mention of a `--purge` option. Did you mean `--force`? – Skrat Feb 12 '19 at 17:48
  • Um, yep, must have been. (--force) Many apologies. @skrat – Bruce Edge Jan 07 '21 at 23:47
14

First find where is the right libruby path, mine is: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib

It is common that the version has changed.

Find out where the absolute path of vim is:

$ which vim
vim: aliased to your-path-of-vim

change dyld:

sudo install_name_tool -change /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib your-path-of-vim
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
John Zhang
  • 611
  • 6
  • 7
  • 3
    This worked with a minor difference. Instead of using `which vim`, use the path indicated in error. In my case, it was `/usr/local/Cellar/macvim/8.1-151/MacVim.app/Contents/bin/../MacOS/Vim` – Anshul Nov 05 '18 at 08:39
12
➜  ~ vim
dyld: Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib
  Referenced from: /usr/local/bin/vim
  Reason: image not found

I tried brew uninstall install update... All failed. And install_name_tool works for me.

install_name_tool -change /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib /usr/local/bin/vim
Hellen
  • 3,472
  • 5
  • 18
  • 25
  • I was in the same situation with none of the other solutions working, but the install_name_tool worked for me, thank you! – J Ellis Apr 22 '18 at 22:26
  • 3
    After tried, I got this error: error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: input file: /usr/local/Cellar/macvim/8.0-143/MacVim.app/Contents/bin/mvim is not a Mach-O file – teleme.io Jul 23 '18 at 04:42
  • 3
    This worked for me, but it was a slightly different binary location. `install_name_tool -change /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib /usr/local/Cellar/macvim/8.1-151/MacVim.app/Contents/MacOS/MacVim` and `install_name_tool -change /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib /usr/local/Cellar/macvim/8.1-151/MacVim.app/Contents/MacOS/Vim` – Juan Chanco Nov 02 '18 at 13:35
  • 2
    Important to note that `/usr/local/bin/vim` should be replaced with whatever the error says is the referencing file. In my case, it was `/usr/local/Cellar/macvim/8.1-151/MacVim.app/Contents/bin/../MacOS/Vim` – abeger Nov 02 '18 at 15:09
7

This worked for me:

$ brew update

$ brew upgrade macvim

actual command output:

[bin]$ brew upgrade macvim
==> Upgrading 1 outdated package, with result:
macvim 8.0-142
==> Upgrading macvim --with-override-system-vim
==> Downloading https://github.com/macvim-dev/macvim/archive/snapshot-142.tar.gz
==> Downloading from https://codeload.github.com/macvim-dev/macvim/tar.gz/snapshot-142
######################################################################## 100,0%
==> ./configure --with-features=huge --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-rubyinterp --enable-tclinterp --enable-ter
==> make
  /usr/local/Cellar/macvim/8.0-142: 2,147 files, 34.2MB, built in 3 minutes 15 seconds
[bin]$ 
Guido
  • 867
  • 9
  • 13
3

What helped in my case was:

brew link --overwrite vim

In your case, it might be useful to use the same command for MacVim

brew link --overwrite macvim
Adrian Grzywaczewski
  • 868
  • 1
  • 12
  • 25
1

Tried to use brew upgrade macvim an error was raised and the failed. What worked for me is to open the MacVim in a normal window (not a iTerm or terminal) the graphic version noticed that a newer version is available and asked if I want to update. Clicked yes, please and done. macvim in terminal or iTerm works just fine (as well as the "window" version).

radical_edo
  • 934
  • 2
  • 11
  • 29