I've not run brew update && brew upgrade for a long time.

I just did a massive upgrade which turned out to broke my Vim.

This is what I got after running vim:

dyld: Library not loaded: /usr/local/opt/ruby/lib/libruby.2.3.0.dylib
  Referenced from: /usr/local/bin/vim
  Reason: image not found
Trace/BPT trap: 5

I've came across some websites but none of them were actually helpful.

They said that it might be related to rvm but brew uninstall vim; rvm system; brew install vim didn't help. I tried to reinstall my MacVim as well but it didn't solve the problem.

Adding export PATH="/usr/local/bin:$PATH" to my .bash_profile didn't help either.

Here's the list for future reference:

What happened to my Vim? How can I fix it?

  • 1
    Now perhaps you could try: xcode-select --install and then brew upgrade, as suggested in section Upgrading macOS at Common Issues
    – taper
    Nov 10, 2017 at 12:12
  • For reference, the issue is discussed here github.com/Homebrew/brew/issues/2356 (but not properly solved, since I ran into a similar issue 5 years after --simply installing ninja broke macvim :/)
    – YvesgereY
    Jan 12, 2021 at 19:56

11 Answers 11



Try to reinstall ruby and vim, e.g.

brew reinstall ruby vim


Here are other suggestions if above won't help:

  • Find any references to DYLD_LIBRARY_PATH, DYLD_FALLBACK_LIBRARY_PATH or DYLD_FRAMEWORK_PATH environmental variables and remove them from the startup shell scripts (e.g. ~/.bashrc, ~/.bash_profile, etc.).
  • 4
    Just upgraded to high sierra and this did the trick! Thanks.
    – e_x_p
    Sep 27, 2017 at 20:19
  • 1
    I was having the issue with mac vim so I used this one instead brew reinstall ruby macvim and worked like a charm :) Dec 17, 2017 at 5:02
  • 7
    After upgrading to high sierra I ran brew update and brew upgrade, which upgraded a lot of software to the high sierra versions and fixed my issue.
    – maffo
    Dec 21, 2017 at 8:29
  • 1
    Thanks that helped! I just run brew reinstall vim it re-installed ruby as well automatically.
    – iluu
    Apr 11, 2020 at 11:34
  • if xcode-select --install failed could download the "Command line tools for Xcode" from developer.apple.com/download/more plase see: developer.apple.com/forums/thread/110552
    – zhuguowei
    Oct 30, 2020 at 4:32


brew link --overwrite ruby


Actually, it turned out to be quite simple. I followed the suggestion to run brew doctor and I got these results:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:

So I ran brew link ruby. This is what I got:

Linking /usr/local/Cellar/ruby/2.3.1... v
Error: Could not symlink bin/rake
Target /usr/local/bin/rake
already exists. You may want to remove it:
  rm '/usr/local/bin/rake'

As a result I decided to run brew link --overwrite ruby and now my Vim is working once again!

  • 2
    Damn brew upgrade does this crap to me a lot. Thank you very much for offering a clear set of instructions to fix this.
    – Sukima
    Jul 15, 2016 at 14:02
  • 2
    Didn't work for me after upgrading to Catalina: Warning: Refusing to link macOS-provided software: ruby
    – Cory Klein
    Nov 19, 2019 at 0:36

I ran into a similar error when doing brew upgrade where libperl doesn't get loaded.

dyld: Library not loaded: /usr/local/opt/perl/lib/perl5/5.24.1/darwin-thread-multi-2level/CORE/libperl.dylib
  Referenced from: /usr/local/Cellar/vim/8.0.0636/bin/vim
  Reason: image not found

Fix was to reinstall the broken dependency and vim:

brew uninstall --ignore-dependencies perl
brew uninstall vim
brew install vim

For me, I found that brew somehow installed macvim and it kept conflicting with OS stock vim. Attempts to use regular vim, and running git commands such as these produced errors:

$ git commit --amend
dyld: Library not loaded: /System/Library/Perl/5.16/darwin-thread-multi-2level/CORE/libperl.dylib
  Referenced from: /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/MacOS/Vim
  Reason: image not found
error: vi died of signal 6
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

So I went ahead and uninstalled any vim-related packages that brew had installed:

$ brew list

And surely removing macvim with $ brew uninstall macvim solved the issue


I tried reinstalling, relinking, removing all available versions etc. for ruby and vim but nothing really helped.

Thus, I just decided to rename my dylib file from




The result of that rename is that it works perfectly fine now.

  • 3
    You might want to consider using a symlink here instead of renaming the file, so that anything that referenced libruby2.3.dylib doesn't break too.
    – Derwent
    Feb 26, 2018 at 2:04

If you get a message like the following:

dyld: Library not loaded: /usr/local/opt/ruby/lib/libruby.2.4.1.dylib
  Referenced from: /usr/local/bin/vim
  Reason: image not found
error: vim died of signal 6
error: There was a problem with the editor 'vim'.
Please supply the message using either -m or -F option.

and you manage your Ruby using rvm, then properly setting one environment variable should get your vim back in action.

Follow these steps to see if it applies to your environment:

Is DYLD_LIBRARY_PATH defined and is it correct?:


Where is Ruby installed?

$ type ruby
ruby is hashed (/Users/<USER>/.rvm/rubies/ruby-2.4.1/bin/ruby)

That shows that my ruby is managed by rvm.

Where is libruby.2.4.1.dylib located?

find /Users/<USER>/.rvm/rubies/ruby-2.4.1  -name "*.dylib"

Add the "lib" directory and append it to your startup file:

echo -e "\nexport DYLD_LIBRARY_PATH=/Users/<USER>/.rvm/rubies/ruby-2.4.1/lib" >> ~/.bashrc

Note: Use which ever startup file (~/.profile, ~/bash_exports, etc.) that makes sense for your workstation.

Now, when you start a new terminal session, your vim should be working again.


On my case it turns out ruby was installed but for reason not linked, so:

brew link ruby


My Error (this occured after homebrew update):

dyld: Library not loaded: /usr/local/opt/ruby/lib/libruby.2.6.dylib Referenced from: /usr/local/bin/vim Reason: image not found [1] 2800 abort vim

This took an hour of my life. My solution:

Reinstall ruby $ brew reinstall ruby

Feedback from Homebrew:

ruby is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH run: echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set: export LDFLAGS="-L/usr/local/opt/ruby/lib" export CPPFLAGS="-I/usr/local/opt/ruby/include"

For pkg-config to find ruby you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig" ==> Summary 🍺 /usr/local/Cellar/ruby/2.6.3: 19,372 files, 32.4MB Error: Could not remove ruby backup keg! Do so manually: sudo rm -rf /usr/local/Cellar/ruby/2.4.2_1.reinstall

I followed homebrew's instructions and manually removed the ruby backup keg

$ sudo rm -rf /usr/local/Cellar/ruby/2.4.2_1.reinstall

After entering password and trying to open vim again with

$ vim

Vim opened and I smiled a bit and brushed away the frustration perspiration. :)


As mentioned here, the following fixed it for me.

brew uninstall macvim && brew install macvim --HEAD

Also, after upgrading to macOS Catilina, I open X-Code in install necessary updates.


I stopped using Homebrew because of all its problems and security issues.

In any case, I upgraded from OSX Yosemite to OSX High Sierra and macvim stopped working in Terminal. I got the error:

dyld: Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib
  Referenced from: /Applications/MacVim.app/Contents/MacOS/Vim
  Reason: image not found
Abort trap: 6

I tried EXPORT'ing a path like in I3x's answer, but I still got the same error(yes, I opened a new Terminal window).

So, I downloaded macvim again. When I was told there was already a MacVim.app on my computer, I stopped the install, and I changed the name to MacVim_original.app. Then I proceed to install a new macvim. After that, macvim worked in Terminal again. I launch it with a shortcut command:

$ m 1.py 
  • 1
    When making statements like “all the problems and security issues,” consider including links to documentation thereof. (= Dec 11, 2017 at 0:34
  • Er. enjoy your downvote, then. I'm simply offering an explanation of why you got one, as is an accepted practice (just like citing your sources) here on Stack Exchange. ¯\_(ツ)_/¯ Dec 15, 2017 at 2:16
brew uninstall --force ruby perl vim && brew install vim 

This is what worked for me.

You must log in to answer this question.

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