Repository navigation
keg: keep versioned opt aliases that still point at an installed keg - #24113
Merged
MikeMcQuaid merged 3 commits intoSep 29, 2026
Merged
Conversation
Uninstall deleted the install receipt before reading aliases, so cleanup treated names such as ruby@4.0 as stale and removed them even when they pointed at the newer keg. Co-authored-by: Cursor <cursoragent@cursor.com>
MikeMcQuaid
reviewed
Sep 29, 2026
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
MikeMcQuaid
reviewed
Sep 29, 2026
Author
|
Thanks for accepting my suggested fix, and improving it to be mergeable! |
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uninstall deletes a keg's
INSTALL_RECEIPT.jsonbeforeremove_old_aliasesreads it. The alias list is then empty, so the versioned opt sweep treats names such asruby@4.0as stale and deletes them when they point anywhere in that formula's rack, including the newer keg. MacVim (and anything else linked against Homebrew Ruby's install name) then aborts withLibrary not loaded: .../opt/ruby@4.0/lib/libruby.4.0.dylib.uninstallnow passes the alias list it read before removing the keg. A versioned opt alias that this keg owns is kept while its target still exists, and removed when that target was the keg just deleted. Stale names that are not aliases of the keg being removed, such as a leftoverffmpeg@8, are still deleted.Fixes the failure discussed in https://github.com/orgs/Homebrew/discussions/7041 and macvim-dev/macvim#1697.
To reproduce:
opt/ruby@4.0is missing andvimaborts.brew unlink ruby && brew link rubybrings the alias back until the next Ruby upgrade.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Drafted with Cursor Grok 4.7. I reviewed the diff and verified it with
brew lgtm(brew typecheck,brew style --changed, andbrew tests --only=keg).Made with Cursor