Make the gem CLI work under RUBY_BOX=1 - #9810
Merged
Merged
Conversation
Under Ruby::Box (RUBY_BOX=1) the builtin Marshal runs in the root box and cannot resolve Gem:: constants defined in the main box, so every gem command failed to start while deep-copying its option defaults. https://bugs.ruby-lang.org/issues/22090 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Under Ruby::Box mkmf makes RbConfig.expand recurse until SystemStackError, so building a native extension failed even once the CLI itself started. Build tools are not a target of box isolation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The unit tests cover each fix on its own, but nothing checks that a boxed gem command actually gets as far as listing gems. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Under Ruby::Box (
RUBY_BOX=1, experimental in Ruby 4.0), everygemcommand fails to start withArgumentError: undefined class/module Gem::because the builtinMarshalruns in the root box and cannot resolveGem::constants defined in the main box (https://bugs.ruby-lang.org/issues/22090). This replaces theMarshal.load Marshal.dumpdeep copies of option defaults with a hand-writtenGem::Util.deep_dup.Native extension builds still fail after that because the
extconf.rbsubprocess inheritsRUBY_BOX=1and hits infinite recursion inRbConfig.expand(SystemStackError, a known ruby-core issue). Build tools are not a target of box isolation, soGem::Ext::Builder.runnow unsetsRUBY_BOXin the subprocess environment.With both fixes,
RUBY_BOX=1 gem installsucceeds including native builds. An integration canary runsgem list --localunderRUBY_BOX=1whenRuby::Boxis available.