fix: subprocess probes inherited a relative BUNDLE_GEMFILE and broke on chdir - #282
Conversation
…on chdir Master has been red for six commits on the (3.3, rails81_gems.rb) cell: six probe tests dying with /tmp/d20260824-4743-risnub/gemfiles/rails81_gems.rb not found (Bundler::GemfileNotFound) All six route through GemNameEntryPointTest.probe, which spawns a bare ruby with `chdir:` a tmpdir and passed NO env, so the child inherited BUNDLER_SETUP. RubyGems ends rubygems.rb with require ENV["BUNDLER_SETUP"] if ENV["BUNDLER_SETUP"] && !defined?(Bundler) so the child re-entered bundler/setup before reaching `-e`, and resolved the workflow's RELATIVE `BUNDLE_GEMFILE: gemfiles/rails81_gems.rb` against the tmpdir. Bundler >= 2.6 rewrites BUNDLE_GEMFILE to an absolute path during setup and the 2.5 that ships with ruby 3.3 does not, which is why only the 3.3 cells saw it -- and why it is invisible locally, where `bundle exec` expands it too. This is the repo's own rule applied by halves: a probe of a tree it built itself must chdir out of the project AND scrub the bundle. The chdir landed; the scrub did not. Fixed as a class, not an instance: - PROBE_ENV in test_helper.rb is now the one child environment for probes that chdir out of the project -- BUNDLER_SETUP, BUNDLE_GEMFILE, RUBYLIB, RUBYOPT. legacy_deletion_test.rb had hand-rolled three of the four (missing BUNDLER_SETUP) and now shares it. - The probes that chdir INTO the project root are untouched: they genuinely want the bundle, and a relative BUNDLE_GEMFILE resolves fine from there. A relative BUNDLE_GEMFILE stays a legitimate thing for the workflow to set, so test.yml is unchanged. - NO_BUNDLE_GATE opens every probe and aborts if the bundle leaked in. Without it the scrub could silently stop working and stay green on every ruby but 3.3 -- exactly how this reached master six times. Under a plain local run, reverting the scrub now fails loudly with "GATE: the probe inherited the development bundle" instead of passing. - That gate is itself tested against the opposite condition: restoring BUNDLER_SETUP alone must make the same probe refuse to run. Verified: rake test:unit green both ways -- normal, and with the env CI uses (CI=true plus a relative BUNDLE_GEMFILE forced back after bundler/setup, which reproduces the 3.3 bundler on any ruby). Under that CI-shaped env the pre-fix probe reproduces the exact CI stack trace at rubygems.rb:1459. rake test:canonical and standardrb lib test green.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughSubprocess probes now use a shared environment that removes Bundler and project load-path settings. The probe helper adds a no-Bundler gate. Legacy deletion probes merge their deleted-tree setting into the shared environment, with coverage for inherited Bundler setup. ChangesProbe isolation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change isolates test subprocesses from inherited bundle settings and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideFix subprocess probes that chdir into temporary or deleted trees by scrubbing inherited Bundler and Ruby environment variables, while adding an executable gate and regression test to ensure probes cannot silently validate the wrong environment. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Master has been red for six consecutive commits on
Test Ruby & Rails (3.3, rails81_gems.rb, false). This unblocks the release.What broke
Six probe tests die with:
All six route through one helper,
GemNameEntryPointTest.probe, which spawns a bare ruby withchdir:a tmpdir and passed no env — so the child inheritedBUNDLER_SETUP. RubyGems endsrubygems.rbwith:The child therefore re-enters
bundler/setupbefore it reaches-e, and resolves the workflow's relativeBUNDLE_GEMFILE: gemfiles/rails81_gems.rbagainst its cwd — the tmpdir.Why only ruby 3.3, and why never locally
Bundler >= 2.6 rewrites
BUNDLE_GEMFILEto an absolute path during setup; the 2.5 that ships with ruby 3.3 leaves it alone. Measured:BUNDLE_GEMFILEafterrequire "bundler/setup"gemfiles/rails81_gems.rb— relative, breaks/abs/path/gemfiles/rails81_gems.rbbundle execexpands it too, which is why every local run was green. The 3.3/rails81 cell failed first and fail-fast cancelled the other 3.3 cells — they were not passing, just unreported.This is the repo's own documented rule applied by halves: a subprocess probe of a tree it built itself must
chdirout of the project and scrub the bundle. The chdir landed; the scrub did not.The fix — class, not instances
PROBE_ENVintest_helper.rbis now the single child environment for probes that chdir out of the project:BUNDLER_SETUP,BUNDLE_GEMFILE,RUBYLIB,RUBYOPT.legacy_deletion_test.rbhad hand-rolled three of the four (missingBUNDLER_SETUP) and now shares it.-Iload paths wants no bundler at all → scrub. Every probe thatchdir: PROJECT_ROOTgenuinely wants the bundle, and a relativeBUNDLE_GEMFILEresolves fine from there → left alone. A relativeBUNDLE_GEMFILEstays a legitimate thing for a workflow to set, so.github/workflows/test.ymlis unchanged.NO_BUNDLE_GATEopens every probe and aborts if the bundle leaked in. Without it the scrub could silently stop working and stay green on every ruby but 3.3 — exactly how this reached master six times.BUNDLER_SETUPalone must make the same probe refuse to run.Verification
Mutation — reverting the scrub, under a CI-shaped env (relative
BUNDLE_GEMFILE), reproduces the CI trace exactly:The same mutation under a plain local run — where the old code was silently green — now fails loudly:
That is the hole this closes. Restore verified byte-identical (sha256
5b6ac333…before and after).Green both ways:
rake test:unit720 runs / 0 failures normally and with the env CI uses (CI=true+ relativeBUNDLE_GEMFILE);rake test:canonical610 runs / 0 failures;standardrb lib test161 files, no offenses.No
version.rborCHANGELOG.mdchanges.🤖 Generated with Claude Code
https://claude.ai/code/session_014BQJX6eWzBj2UTm5zQsjEs
Summary by Sourcery
Prevent subprocess probes from inheriting the development bundle when they run from temporary or deleted project trees.
Bug Fixes:
Enhancements:
Tests:
Summary by CodeRabbit
Bug Fixes
Tests