Skip to content

unlink: preserve non-keg-only versioned links#21700

Merged
MikeMcQuaid merged 1 commit intomainfrom
unlink_keg_only_fix
Mar 9, 2026
Merged

unlink: preserve non-keg-only versioned links#21700
MikeMcQuaid merged 1 commit intomainfrom
unlink_keg_only_fix

Conversation

@MikeMcQuaid
Copy link
Member

@MikeMcQuaid MikeMcQuaid commented Mar 9, 2026

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 python@3.13 and python@3.14 when 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

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
Copilot AI review requested due to automatic review settings March 9, 2026 19:33
@MikeMcQuaid MikeMcQuaid enabled auto-merge March 9, 2026 19:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_formulae to 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.

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 033123b Mar 9, 2026
40 checks passed
@MikeMcQuaid MikeMcQuaid deleted the unlink_keg_only_fix branch March 9, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants