Skip to content

autoremove: handle runtime dependencies#21574

Closed
wu21-web wants to merge 40 commits intoHomebrew:mainfrom
wu21-web:main
Closed

autoremove: handle runtime dependencies#21574
wu21-web wants to merge 40 commits intoHomebrew:mainfrom
wu21-web:main

Conversation

@wu21-web
Copy link

@wu21-web wu21-web commented Feb 14, 2026

Fixes #21511

  • 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.
    Yes. Github Copilot was used in some debugging and styling modifications. I came up with the fix. I referenced sobert docs to verify the changes applied.

I noticed that the previous solution of modifying cleanup.rb in /Library/Homebrew/cmd and /Library/Homebrew/ is over-complicated and incorrect. Modifying autoremove.rb in libutils would be much easier.

Added handling for runtime dependencies in autoremove.
Ensures build dependencies are only kept for formulae built from source, not for bottles
Added mock for `runtime_dependencies` to avoid InstanceDouble errors in tests.
Get rid of test failure in CI workers.
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good so far! Please keep this in the same PR and don't open new PRs, instead just squash your history if things get messy.

wu21-web and others added 2 commits February 14, 2026 22:08
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@MikeMcQuaid MikeMcQuaid changed the title Resolve Issue #21511 by adding handling for runtime dependencies in autoremove Handling runtime dependencies in autoremove Feb 14, 2026
@MikeMcQuaid MikeMcQuaid changed the title Handling runtime dependencies in autoremove Hande runtime dependencies in autoremove Feb 14, 2026
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@MikeMcQuaid MikeMcQuaid changed the title Hande runtime dependencies in autoremove autoremove: handle runtime dependencies Feb 14, 2026
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@MikeMcQuaid
Copy link
Member

@wu21-web please ensure you:

  • review all AI generated code locally before you push
  • please don't have you and/or the AI add more obvious comments

@wu21-web
Copy link
Author

OK. Thanks for the tip.

@wu21-web wu21-web requested a review from MikeMcQuaid February 15, 2026 14:41
@wu21-web wu21-web marked this pull request as ready for review February 16, 2026 00:27
Copilot AI review requested due to automatic review settings February 16, 2026 00:27
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 autoremove logic to better account for runtime dependencies so brew cleanup doesn’t suggest/removal-attempt formulae that are still required by currently-installed formulae after dependency graph changes (Fixes #21511).

Changes:

  • Update Utils::Autoremove to consider runtime dependencies in addition to installed_runtime_formula_dependencies.
  • Modify/remove existing autoremove specs (currently replaced with non-test code).
  • Remove various inline comments/version annotations from the CI workflow.

Reviewed changes

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

File Description
Library/Homebrew/utils/autoremove.rb Adjusts removable-formula computation to include runtime dependencies when building the “keep” set.
Library/Homebrew/test/utils/autoremove_spec.rb Replaces the RSpec test suite with a duplicate module definition (breaks test coverage).
.github/workflows/tests.yml Removes pinned-action version comments and several rationale comments from CI workflow steps.
Comments suppressed due to low confidence (1)

.github/workflows/tests.yml:183

  • The removed explanatory comments around these steps (e.g. rationale for caching/CI behavior) make the workflow harder to maintain because the decisions are non-obvious. Please keep/restore the rationale comments unless they were incorrect.
        run: brew install-bundler-gems --groups=all

      - name: Check for uncommitted RubyGems
        working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
        run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby

💡 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 2 out of 2 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 2 out of 2 changed files in this pull request and generated 3 comments.


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

wu21-web and others added 3 commits February 21, 2026 19:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 2 out of 2 changed files in this pull request and generated 3 comments.


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

wu21-web and others added 2 commits February 21, 2026 21:09
simplified line 77

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 2 out of 2 changed files in this pull request and generated 2 comments.


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

wu21-web and others added 2 commits February 21, 2026 23:14
rename context

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Re-add comments for easy documentation.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 2 out of 2 changed files in this pull request and generated no new comments.


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

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Your AI is making a bunch of shitty unnecessary changes. Please rereview this line by line and remove unnecessary changes or close this PR.

@wu21-web
Copy link
Author

Sorry for being unable to handle the issue. I don't take programming as a career and I am only a starter with ruby. My apologies for that.

@wu21-web wu21-web closed this Feb 22, 2026
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.

brew cleanup says libthai can be removed, but at the same time it is needed by pango

4 participants