unlink: preserve non-keg-only versioned links#21700
Merged
MikeMcQuaid merged 1 commit intomainfrom Mar 9, 2026
Merged
Conversation
Adjust unlink_link_overwrite_formulae so non-keg-only formulae only unlink linked keg-only overwrite siblings before relinking. This avoids removing coexistable versioned links like python3.13 and python3.14 when linking non-keg-only formula families, while keeping the existing full-unlink behavior for keg-only formulae. Update unlink_spec to cover both behaviors: - non-keg-only formulae only unlink linked keg-only siblings - keg-only formulae still unlink all linked overwrite siblings
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Homebrew’s unlink behavior during relinking so that non-keg-only formulae do not unnecessarily unlink coexistable, non-keg-only “overwrite sibling” formulae (e.g., versioned siblings), while preserving the existing behavior for keg-only formulae.
Changes:
- Narrow
unlink_link_overwrite_formulaeto only unlink linked keg-only siblings when the formula being linked is non-keg-only. - Keep unlinking all linked overwrite siblings when the formula being linked is keg-only.
- Add RSpec coverage for both the non-keg-only and keg-only behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
Library/Homebrew/unlink.rb |
Adjusts sibling selection logic before unlinking to preserve coexistable non-keg-only links. |
Library/Homebrew/test/unlink_spec.rb |
Adds tests asserting the new filtering behavior for non-keg-only vs keg-only formulae. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
p-linnane
approved these changes
Mar 9, 2026
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.
Adjust
unlink_link_overwrite_formulaeso non-keg-only formulae only unlink linked keg-only overwrite siblings before relinking.This avoids removing coexistable versioned links like
python@3.13andpython@3.14when linking non-keg-only formula families, while keeping the existing full-unlink behaviour for keg-only formulae.Fixes https://github.com/orgs/Homebrew/discussions/6744