Skip to content

doctor: skip removed formulae in unlinked check - #24466

Merged
HaraldNordgren merged 1 commit into
mainfrom
doctor-unlinked-removed-from-tap
Nov 4, 2026
Merged

HaraldNordgren merged 1 commit into
mainfrom
doctor-unlinked-removed-from-tap

Conversation

@HaraldNordgren

Copy link
Copy Markdown
Member

brew doctor told me to find replacements for six and python@3.8, then told me to link them:

Warning: Some installed kegs have no formulae!
This means they were either deleted or installed manually.


You should find replacements for the following formulae:

  terraform
  go@1.14
  grv
  exa
  unrar
  openssl@1.1
  six
  python@3.8
  packer

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built.

Run `brew link` on these:
  mercurial
  sphinx-doc
  six
  docker-compose
  python@3.8
  ruby

The second warning is wrong for those two. Once a formula is gone from its tap, Formulary.from_rack loads the copy saved in the keg's .brew/ directory, and that copy can be out of date. python@3.8 became keg-only on 2020-10-28, but my keg was installed earlier that month, so its copy says it isn't keg-only. Following the advice with brew link --overwrite python@3.8 would take python3 and pip3 away from python@3.15.

This skips kegs that Keg#deleted_formula? flags, because check_deleted_formula already reports them. six and python@3.8 drop out of the list, and the other four are still suggested. Kegs installed from a local file also count as deleted, so they're no longer suggested for linking either, but they're still listed under "no formulae".

To reproduce:

mkdir -p "$(brew --cellar)/removed-formula/1.0"
brew doctor check_deleted_formula check_for_unlinked_but_not_keg_only
rmdir "$(brew --cellar)/removed-formula/1.0" "$(brew --cellar)/removed-formula"

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code (Claude Opus 5.5) traced why brew doctor gave both warnings, wrote the change and its specs and verified them. The new spec for removed formulae fails without the change and passes with it. It ran the reproduction steps before and after the change, ran the new check against my install and ran brew lgtm, which passes.


- `check_deleted_formula` already tells users to find replacements
  for these kegs, but `check_for_unlinked_but_not_keg_only` also
  asks to `brew link` them.
- With no formula in any tap, `Formulary.from_rack` loads the keg's
  `.brew/` copy, which can predate it becoming keg-only, so linking
  `python@3.8` with `--overwrite` would take `python3` from the
  current Python.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Diagnostic checks no longer flag unlinked kegs when their formula has been removed.
    • Unlinked kegs continue to be reported when the formula is available.

The unlinked-keg diagnostic now excludes kegs associated with deleted formulae. Tests cover the diagnostic result when the formula is available and when it has been removed.

Changes: Unlinked-keg diagnostic

Layer / File(s) Summary
Filter unlinked kegs and test outcomes
Library/Homebrew/diagnostic.rb, Library/Homebrew/test/diagnostic_checks_spec.rb
The diagnostic excludes kegs marked as belonging to deleted formulae. Tests verify that an available formula produces a brew link suggestion and that a removed formula produces no finding.
Merge Risk: Minimal · up to 13b4d

The change preserves linking advice for available formulae and avoids duplicate advice for removed formulae, with no merge-blocking risk identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Description check Passed The description clearly explains the bug, the cause, the intended fix, reproduction steps, tests, and validation results. It is directly related to the changeset.
Title check Passed The title clearly and concisely describes the main change: excluding removed formulae from the unlinked-keg check.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1a3cc3cd-d03f-4bec-b1ab-3e722107a6fa
Commits

Reviewing files that changed from the base of the PR and between 7a9af24 and 13b4d28.

Files selected for processing: 2
  • Library/Homebrew/diagnostic.rb
  • Library/Homebrew/test/diagnostic_checks_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, thanks!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge November 4, 2026 09:03
@HaraldNordgren
HaraldNordgren added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit c6cff8a Nov 4, 2026
59 checks passed
@HaraldNordgren
HaraldNordgren deleted the doctor-unlinked-removed-from-tap branch November 4, 2026 11:26
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.

2 participants

⌂ 换网址