Skip to content

Conversation

@cho-m
Copy link
Member

@cho-m cho-m commented Nov 20, 2025

  • 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?

This allows replacing some Homebrew/core system library checks where we are using Pathname#dynamically_linked_libraries (which will break if we stop monkey-patching Pathname).

For example

The previous code skipped over non-Homebrew libraries and would always run realpath which is not guaranteed to exist for macOS system libraries.


This won't handle checking a symlinked system library. However, this feature isn't needed as it would only be used for Linux libraries but we already audit unwanted system library linkage.

If there is ever a case we want to check symlinked system library, could add an exist? check and then run realpath.

Copilot AI review requested due to automatic review settings November 20, 2025 18:33
Copilot finished reviewing on behalf of cho-m November 20, 2025 18:36
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 enhances the Utils.binary_linked_to_library? method to support checking linkage to non-Homebrew (system) libraries, addressing a limitation in the previous implementation that only handled Homebrew libraries.

Key Changes:

  • Modified the linkage checking logic to conditionally resolve symlinks only for Homebrew-prefix libraries
  • Added support for checking non-Homebrew library linkage (e.g., system libraries in /usr/lib)
  • Added test coverage for the new non-Homebrew library checking functionality

Reviewed Changes

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

File Description
Library/Homebrew/utils/linkage.rb Refactored binary_linked_to_library? to conditionally call File.realpath only for HOMEBREW_PREFIX paths, enabling non-brew library checks
Library/Homebrew/test/utils/linkage_spec.rb Added test case to verify non-brew library linkage checking works correctly

💡 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.

Looks good, thanks!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 21, 2025
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 21, 2025
@cho-m cho-m added this pull request to the merge queue Nov 21, 2025
Merged via the queue into main with commit c0ea918 Nov 21, 2025
43 checks passed
@cho-m cho-m deleted the linkage-check-non-brew-libs branch November 21, 2025 14:53
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