Skip to content

formula: imply link_overwrite for related formulae#21689

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

formula: imply link_overwrite for related formulae#21689
MikeMcQuaid merged 1 commit intomainfrom
implied_link_overwrite

Conversation

@MikeMcQuaid
Copy link
Member

Treat Homebrew-owned conflicts from related formula families as implied link_overwrite paths when linking versioned or -full formulae.

This restores the version-switching behavior that regressed for cases like installing node@22 after uninstalling node left npm files behind in the prefix.

While we're here, add some AGENTS.md changes based on feedback.

Follow-up from #21684
References Homebrew/homebrew-core#271139

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

OpenAI Codex with ~4-5 manual review passes and editing.


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

This PR restores expected version-switching behavior when linking versioned or -full formulae by treating Homebrew-owned conflicts from related formula families as implied link_overwrite candidates (e.g., cleaning up leftover npm files when switching nodenode@22). It also adds tests around the new/adjusted conflict handling and updates agent contribution guidance.

Changes:

  • Extend Formula#link_overwrite? to allow implied overwrites for conflicts owned by Homebrew when they are related to the current formula family.
  • Add unit/spec coverage for the new implied-overwrite behavior and for formula-aware unlinking during brew link.
  • Update AGENTS.md with additional testing and spec-authoring guidance.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
Library/Homebrew/formula.rb Implements implied overwrite logic for related formula families during linking.
Library/Homebrew/test/formula_spec.rb Adds a unit spec covering implied overwrite when a conflict path isn’t in any keg.
Library/Homebrew/test/cmd/link_spec.rb Adds a unit spec ensuring brew link uses formula-aware unlink handling.
AGENTS.md Adds guidance on red/green test cycles and stubbing patterns in specs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid marked this pull request as draft March 8, 2026 16:29
@MikeMcQuaid MikeMcQuaid force-pushed the implied_link_overwrite branch 2 times, most recently from d33de6b to 126feee Compare March 8, 2026 19:44
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review March 8, 2026 19:44
@MikeMcQuaid MikeMcQuaid requested a review from Copilot March 8, 2026 19:44
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid force-pushed the implied_link_overwrite branch from 9afb55e to bfdf474 Compare March 9, 2026 09:01
Treat Homebrew-owned conflicts from related formula families as implied
`link_overwrite` paths when linking versioned or -full formulae.

This restores the version-switching behavior that regressed for cases
like installing `node@22` after uninstalling `node` left `npm` files
behind in the prefix.

While we're here, add some `AGENTS.md` changes based on feedback.

References Homebrew/homebrew-core#271139
@MikeMcQuaid MikeMcQuaid force-pushed the implied_link_overwrite branch from bfdf474 to 19a79a7 Compare March 9, 2026 09:28
@MikeMcQuaid MikeMcQuaid enabled auto-merge March 9, 2026 09:28
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit d4c058e Mar 9, 2026
38 checks passed
@MikeMcQuaid MikeMcQuaid deleted the implied_link_overwrite branch March 9, 2026 14:23
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