After flattening, lib/ holds both RubyGems and Bundler, so any dev binstub
that puts the worktree lib/ on $LOAD_PATH now overlays the already-booted
system RubyGems with the worktree one. bin/bundle hit this through the
Bundler gemspec activation: the partial overlay mixed a worktree Gem with
an older system Gem::ConfigFile, breaking native extension installs on Ruby
3.2/3.3 (undefined install_extension_in_lib) and corrupting spec names
elsewhere. The same overlay breaks bin/rake, bin/ronn, bin/rubocop and
bin/mdl, which unshift the worktree lib/ (or require it through
rubygems_ext) but boot on the system RubyGems. On a host whose RubyGems
differs from the worktree copy this double-loads files like rubygems/package
and raises (undefined method `spec=' for class Gem::Package::Old).
Route all of them through switch_rubygems, like bin/rspec and bin/test-unit
already do, so they re-exec onto the worktree RubyGems before anything is
loaded. Point the shared gem home job at the worktree copy too, since the
dev binstub can no longer load a separately installed RubyGems, and the
matrix is redundant for now.
https://github.com/ruby/rubygems/commit/f50eb4216d
With spec/ at the repo root, rspec auto-adds lib/ to $LOAD_PATH,
which now points to the repo's rubygems lib instead of bundler's lib.
This causes a conflict between system and local rubygems. Adding
switch_rubygems ensures a clean local rubygems load from the start.
Also default RGV to "." so no environment variables are needed to
run bin/rspec or bin/parallel_rspec.
https://github.com/ruby/rubygems/commit/b4774e3aab
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>