Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable Ruby 3.1.4 (opt-in beta) #16145

Merged
merged 3 commits into from Oct 27, 2023
Merged

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Oct 26, 2023

Adds a HOMEBREW_RUBY3 variable that enables Portable Ruby 3.1.4.

This is opt-in, disabled by default. Over the coming weeks we can enable this by default in increasing audiences. Once it is rolled out to everyone, then we can drop Ruby 2.6 support, update dependencies, and then update RuboCop to target a 3.1 minimum (in that order).

At some point we will also need to vendor Ruby 3.1 gems, and we will need to decide when that is. Expect 0.75-1s slower startup times under Ruby 3 until that happens.

I'm intentionally not enabling this by default for anyone in this PR because:

  • It would be good to get a couple maintainers on each of the three platforms to run with this for a couple days.
  • Enabling for HOMEBREW_DEVELOPER is still a big change as that affects all of homebrew-core and homebrew-cask CI which has largely been untested so far, so a separate PR that can be reverted independently is best. The impact of the performance penalty on CI is also unclear.

@SMillerDev
Copy link
Member

Once we get to the rollout stage it would probably be good to ship this in the macOS package too.

@MikeMcQuaid
Copy link
Member

almost every command failing for me with the same error:

mikebook # brew info ack --debug                                   (portable-ruby-3) [~/OSS/Homebrew]
Error: can not make shareable object for #<Thread::Mutex:0x0000000103042de8>
<internal:ractor>:820:in `make_shareable'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/did_you_mean/spell_checkers/require_path_checker.rb:12:in `<class:RequirePathChecker>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/did_you_mean/spell_checkers/require_path_checker.rb:8:in `<module:DidYouMean>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/did_you_mean/spell_checkers/require_path_checker.rb:7:in `<main>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/did_you_mean.rb:9:in `require_relative'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/did_you_mean.rb:9:in `<main>'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/homebrew/Library/Homebrew/formula.rb:5:in `<main>'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/homebrew/Library/Homebrew/cmd/info.rb:8:in `<main>'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/homebrew/Library/Homebrew/extend/kernel.rb:10:in `require?'
/opt/homebrew/Library/Homebrew/commands.rb:41:in `valid_internal_cmd?'
/opt/homebrew/Library/Homebrew/brew.rb:65:in `<main>'

Works if I disable bootsnap:

mikebook # export HOMEBREW_NO_BOOTSNAP=1                           (portable-ruby-3) [~/OSS/Homebrew]
mikebook # brew info ack --debug                                   (portable-ruby-3) [~/OSS/Homebrew]
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading ack from API
==> ack: stable 3.7.0 (bottled), HEAD
...

Fine if I delete bootsnap files in the cache and re-enable bootsnap.


I have an unusual multi-user/group writable permission setup right now and seeing some permission weirdness around Library/Homebrew/vendor/bundle/ruby/.homebrew_gem_groups and Can't create vendor-install-ruby lock in /opt/homebrew/var/homebrew/locks. Not a blocker there at all but does mean I'm probably not going to be able to test this as my default configuration until it's the default Ruby version for everyone or I'm able to have a way to ensure Ruby is configured/setup as the right user.

I've opened a PR in #16147 (which could be merged in here instead, if desired) to provide a brew setup-ruby command to guarantee that the next invocation will not need to try to install Ruby or install gems. Let me know your thoughts @Bo98.

@Bo98
Copy link
Member Author

Bo98 commented Oct 27, 2023

Error: can not make shareable object for #<Thread::Mutex:0x0000000103042de8>

Fine if I delete bootsnap files in the cache and re-enable bootsnap.

Ah, that looks to be the same error we saw with Ruby's own builds in ruby/setup-ruby.

We can probably change the Bootsnap cache to be $HOMEBREW_CACHE/bootsnap/RUBY_VERSION-RUBY_PLATFORM or similar. Bootsnap is supposed to invalidate the cache itself but it must not work properly for some reason.

I have an unusual multi-user/group writable permission setup right now and seeing some permission weirdness

If you have more info, it's worth opening an issue about it - it likely also happens with HOMEBREW_USE_RUBY_FROM_PATH and HOMEBREW_FORCE_VENDOR_RUBY. The lock failing in particular is very odd given brew update should use an identical lock mechanism.

@MikeMcQuaid
Copy link
Member

We can probably change the Bootsnap cache to be $HOMEBREW_CACHE/bootsnap/RUBY_VERSION-RUBY_PLATFORM or similar. Bootsnap is supposed to invalidate the cache itself but it must not work properly for some reason.

Another (potentially easier) option: just nuke the cache whenever we install a new Ruby version.

If you have more info, it's worth opening an issue about it - it likely also happens with HOMEBREW_USE_RUBY_FROM_PATH and HOMEBREW_FORCE_VENDOR_RUBY. The lock failing in particular is very odd given brew update should use an identical lock mechanism.

I'll reach out to you on Slack but I think #16147 or similar would be sufficient for me to proceed.

@MikeMcQuaid
Copy link
Member

Once we get to the rollout stage it would probably be good to ship this in the macOS package too.

@SMillerDev To do this: we'll need to sign all the portable Ruby binaries.

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 to me 👍🏻

@MikeMcQuaid MikeMcQuaid merged commit b5aec54 into Homebrew:master Oct 27, 2023
29 checks passed
@MikeMcQuaid
Copy link
Member

Great work @Bo98

@Bo98 Bo98 deleted the portable-ruby-3 branch October 27, 2023 20:11
@github-actions github-actions bot added the outdated PR was locked due to age label Nov 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants