Skip to content

Conversation

@cho-m
Copy link
Member

@cho-m cho-m commented Nov 19, 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?

Fixes #21109

This PR removes portable Ruby from PATH as parts of brew are written expecting only system paths like

rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact

I am not entirely sure on setup_gem_environment! change, but it restores original behavior before 60fa368#diff-a1a5395d198aee1fb8c45c74bf9dd49ef5734887a17ee84000badc7d58b82e98L43 (called via install_bundler!)

This mainly is used to avoid a failing test (utils/ruby_check_version_script_spec.rb).

Though maybe the test shouldn't be using Ruby from PATH as that is not how we interact with the script. We usually call the script like <path/to/ruby> ruby_check_version_script_spec.rb ... so it doesn't matter whether or not portable Ruby is on the PATH.


EDIT: After thinking over above, will just adjust test rather than adding setup_gem_environment!. Also in line with the Copilot review that setup_gem_environment! has side effects that we may not have intended.

May need to keep an eye out for unexpected failures though if any code is expecting portable Ruby on PATH.

Copilot AI review requested due to automatic review settings November 19, 2025 02:52
Copilot finished reviewing on behalf of cho-m November 19, 2025 02:56
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 removes the portable Ruby bin directory from PATH in the shell script (ruby.sh) and adds a call to setup_gem_environment! in the valid_gem_groups method to restore gem environment setup through Ruby code instead. The main motivation is to fix a failing test (ruby_check_version_script_spec.rb) that was picking up the portable Ruby from PATH.

Key Changes

  • Removed PATH modification in shell script that added portable Ruby bin directory
  • Added setup_gem_environment! call at the start of valid_gem_groups method
  • Shifts PATH setup responsibility from shell to Ruby code

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Library/Homebrew/utils/ruby.sh Removes the line that adds portable Ruby bin directory to PATH after installing bundler
Library/Homebrew/utils/gems.rb Adds setup_gem_environment! call to valid_gem_groups to ensure gem environment is set up before querying bundler groups

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

@cho-m cho-m force-pushed the remove-portable-ruby-path branch from 1b862c8 to c9c6812 Compare November 19, 2025 03:17
@cho-m cho-m marked this pull request as ready for review November 19, 2025 03:19
Copilot AI review requested due to automatic review settings November 19, 2025 03:19
Copilot finished reviewing on behalf of cho-m November 19, 2025 03:22
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.

Looks good, thanks @cho-m!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 19, 2025
Merged via the queue into main with commit 19b3c58 Nov 19, 2025
43 checks passed
@MikeMcQuaid MikeMcQuaid deleted the remove-portable-ruby-path branch November 19, 2025 08:52
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 reinstalls and removes portable ruby

3 participants