utils/rubocop: activate installed platform Rubydex gem - #23565
Merged
Conversation
Signed-off-by: Patrick Linnane <patrick@linnane.io>
MikeMcQuaid
enabled auto-merge
August 19, 2026 16:34
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes brew style on non-macOS-arm64 platforms by ensuring the platform-appropriate rubydex gem is activated before RuboCop loads, despite a vendored bundler/setup.rb that hardcodes a macOS arm64 Rubydex load path.
Changes:
- Activate the installed platform-specific
rubydexgem (when its require paths are not already present on$LOAD_PATH) before requiring RuboCop. - Add a spec that simulates a missing Rubydex load path and asserts
rubocop -Vreports+Rubydex.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Library/Homebrew/utils/rubocop.rb | Activates the installed platform-specific Rubydex gem before RuboCop loads. |
| Library/Homebrew/test/rubocop_spec.rb | Adds a regression test to ensure Rubydex is loaded from the installed platform gem outside the Homebrew environment. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Library/Homebrew/vendor/bundle/bundler/setup.rbis committed and was generated on macOS arm64, so it hardcodesgems/rubydex-0.3.0-arm64-darwin/lib. Other platforms install a different build (Linux aarch64 getsrubydex-0.3.0-aarch64-linux), that path does not exist, andrequire "rubydex"fails.Library/.rubocop.ymlsetsAllCops/UseProjectIndex: true, so RuboCop skips the project index and the cops that use it fall back to file-local behavior.brew styleis weaker off macOS arm64.To reproduce, run
brew styleon Linux and noteAllCops/UseProjectIndex is enabled but the rubydex gem is not installedon stderr.This activates the installed Rubydex specification through RubyGems before RuboCop loads, and only when its require path is missing from
$LOAD_PATH. RubyGems filters by platform, so it picks the build that is installed rather than the one baked into the standalone bundle. On macOS arm64 the guard is a no-op, and a missing gem still falls back to RuboCop's existing behavior. The new spec drops Rubydex from$LOAD_PATHand requiresrubocop -Vto report+Rubydex.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5) drafted the implementation and tests; I reviewed the diff, verified the new test fails without the fix and passes with it, and ran
brew lgtmplus targeted specs.