Make the RubyGems test suite green under RUBY_BOX=1 - #9826
Open
hsbt wants to merge 9 commits into
Open
Conversation
Under RUBY_BOX=1 every spawned ruby prints an experimental warning to stderr, which breaks tests asserting on subprocess output. Prepend -W:no-experimental to RUBYOPT for child processes and add a ruby_box_enabled? helper for box-specific guards.
Ruby::Box leaves $? uninitialized, so exit status checks read exit 0 regardless of the real status. Under RUBY_BOX=1 this made Gem::Source::Git#rev_parse swallow git rev-parse failures, and made the cargo availability pend in the test suite misjudge a broken toolchain as usable. Process.last_status reports the real status in both modes.
Ruby::Box gives each box detached copies of the stdio globals, so reassigning or reopening $stdout/$stderr cannot capture output written by Kernel#warn, Kernel#puts or subprocesses, and $VERBOSE = nil cannot silence category warnings in assert_ractor children. Pend the affected tests until https://bugs.ruby-lang.org/issues/21867 is resolved.
Marshal in the main box cannot resolve Gem:: and other boxed constants, so loading dumps of Gem::Specification, Gem::Version or Date raises ArgumentError under RUBY_BOX=1. Pend the affected tests until https://bugs.ruby-lang.org/issues/22090 is resolved.
The suite is green under RUBY_BOX=1 now, so run it on ruby-head as a canary to catch regressions on either side early.
yamllint rejects the redundantly quoted matrix name. The cargo tests require the installed gem with -r, which bypasses gem activation under RUBY_BOX=1 because the command line require does not go through the RubyGems Kernel#require override, so require inside -e instead.
Under RUBY_BOX every ruby subprocess spawned by the specs prints a two-line experimental warning to stderr, breaking specs that assert clean stderr. Strip those lines when the host ruby has boxes enabled, instead of injecting -W:no-experimental into RUBYOPT, because several specs assert the exact RUBYOPT propagated to subprocesses.
The special-characters and whitespace contexts stubbed File.expand_path for every argument. Under RUBY_BOX=1 with the turbo_tests workers, Bundler::Settings is still unloaded when these examples run, and reading the repository .bundle/config triggers a lazy require of rubygems/yaml_serializer. The default gem activation path in Kernel#require then resolves paths through the stub and crashes with Errno::ENOENT on a fake gemspec path. Stub only the expansion of bundler/setup, which is all these examples need faked.
The example passes RUBYOPT=-rnative_child to the bundle install subprocess, but under RUBY_BOX=1 require_libraries_in_main_box calls rb_require_string directly and bypasses the RubyGems Kernel#require override, so the gem is never activated and the require raises LoadError. This is an unreported ruby-core bug related to [Bug #21760] item 3, and the scenario itself is legitimate, so skip it until the Ruby::Box require semantics are settled upstream.
hsbt
force-pushed
the
ruby-box-green-round1
branch
from
August 31, 2026 08:38
bcc02be to
5f2d481
Compare
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.
Running the test suite with
RUBY_BOX=1failed 38 tests and errored 18 on ruby master. This makes it green in both modes as the first step of Ruby::Box support in the test suite.The harness now prepends
-W:no-experimentaltoRUBYOPTfor spawned processes, since every child ruby prints the Ruby::Box experimental warning to stderr and breaks assertions on subprocess output. Checks reading$?move toProcess.last_statusbecause Ruby::Box leaves$?uninitialized, which also fixesGem::Source::Git#rev_parseswallowinggit rev-parsefailures at runtime. Tests that capture stdio or round-tripGem::constants throughMarshalare pended under Ruby::Box with references to https://bugs.ruby-lang.org/issues/21867 and https://bugs.ruby-lang.org/issues/22090, and are unaffected in normal runs.TestGemRDocnow preloadsrdoc/rdocbefore the tests fakeGem.paths, which was broken on rdoc 8 environments regardless of Ruby::Box.