Macvim from Homebrew formula missing ruby@4.0 #1697
Copy link
Copy link
Open
Description
Steps to reproduce
Install macvim via homebrew via brew install macvim and then either launch the macvim via GUI or terminal. The error message I got is:
dyld[20899]: Library not loaded: /opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib
Referenced from: <52A6DA3C-2DB7-33B3-B925-C83D0C432B8E> /opt/homebrew/Cellar/macvim/9.2.0321/MacVim.app/Contents/MacOS/Vim
Reason: tried: '/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib' (no such file), '/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib' (no such file)
Expected behaviour
Launch correctly
Version of MacVim
9.2.0321
MacVim installation method
Homebrew formula: brew install macvim
Environment
macOS 26.6.2
Logs and stack traces
dyld[20830]: Library not loaded: /opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib
Referenced from: <52A6DA3C-2DB7-33B3-B925-C83D0C432B8E> /opt/homebrew/Cellar/macvim/9.2.0321/MacVim.app/Contents/MacOS/Vim
Reason: tried: '/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib' (no such file), '/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylib' (no such file)Vim and MacVim configuration where issue is reproducable
No response
How was MacVim launched?
- by launching MacVim.app in macOS (by using the Dock, Spotlight, or the
opencommand) - by running mvim/gvim in the terminal
Issue has been tested with clean configuration
- by running
mvim --clean(orgvim, supplied by MacVim distribution). You can also use the File → "New Clean Window" menu item within MacVim. - by running
vim --clean(in terminal, supplied by MacVim distribution) - by running
vim --clean(in terminal, other suppliers, e.g. /usr/bin/vim)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
eirnym commentedon Aug 31, 2026
You always can put correct path for ruby interpreter via a setting in a MacVim's (g)vimrc.
Pluies commentedon Sep 8, 2026
I ran into the same issue and tried setting the interpreter via
~/.vimrcas:But it did not work.
Instead, I symlinked the necessary ruby dylib from the ruby installed by homebrew:
It's ugly, but it works 🤷
chache17 commentedon Sep 18, 2026
This worked for me. Thanks a lot.
eirnym commentedon Sep 19, 2026
It's worth a while to look into formula as I don't see such messages from the GitHub release.
My guess, formula changes from dynamic library linking to static, and Homebrew build environment is different from actual run environment.
I personally don't use Homebrew, so I can't check if dynamic library for the GitHub release is loading correctly.
Mizux commentedon Sep 23, 2026
A little bit more cleaner, regenerate the ruby@4 symlink using:
brew unlink ruby && brew link rubyref: https://github.com/orgs/Homebrew/discussions/7041#discussioncomment-18209263
erikdw commentedon Sep 29, 2026
This is fixed on the Homebrew side by Homebrew/brew#24113 (merged 2026-09-29). MacVim is fine: its bottle links
/opt/homebrew/opt/ruby@4.0/lib/libruby.4.0.dylibbecause that is the install name therubyformula publishes.brew upgrade rubywas deleting theopt/ruby@4.0alias while uninstalling the previous keg.The fix is on Homebrew's main branch. It is not in the 7.0.7 release, so
brew updateis what picks it up.Two cases:
Ruby was already upgraded or reinstalled on a Homebrew from before that fix, so
opt/ruby@4.0is already gone. Updating Homebrew does not recreate it. Run this once:brew unlink ruby && brew link rubyMacVim starts again. Later Ruby upgrades keep the alias, as long as Homebrew includes the fix.
Homebrew is updated to a version that includes the fix while
opt/ruby@4.0still exists. A laterbrew upgrade rubyleaves that alias in place, so MacVim keeps working with no extra step.