Skip to content

utils/rubocop: activate installed platform Rubydex gem - #23565

Merged
MikeMcQuaid merged 1 commit into
mainfrom
rubocop-rubydex-platform-gem
Aug 19, 2026
Merged

utils/rubocop: activate installed platform Rubydex gem#23565
MikeMcQuaid merged 1 commit into
mainfrom
rubocop-rubydex-platform-gem

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

Library/Homebrew/vendor/bundle/bundler/setup.rb is committed and was generated on macOS arm64, so it hardcodes gems/rubydex-0.3.0-arm64-darwin/lib. Other platforms install a different build (Linux aarch64 gets rubydex-0.3.0-aarch64-linux), that path does not exist, and require "rubydex" fails. Library/.rubocop.yml sets AllCops/UseProjectIndex: true, so RuboCop skips the project index and the cops that use it fall back to file-local behavior. brew style is weaker off macOS arm64.

To reproduce, run brew style on Linux and note AllCops/UseProjectIndex is enabled but the rubydex gem is not installed on 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_PATH and requires rubocop -V to report +Rubydex.


  • 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 Hyperfine benchmarks.
  • 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 (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 lgtm plus targeted specs.


Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copilot AI lite review requested due to automatic review settings August 19, 2026 16:27

@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!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge August 19, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 rubydex gem (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 -V reports +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.

Comment thread Library/Homebrew/utils/rubocop.rb
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 19, 2026
Merged via the queue into main with commit a69f950 Aug 19, 2026
47 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the rubocop-rubydex-platform-gem branch August 19, 2026 17:03
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