Skip to content

Fix bundle clean assertion on Bundler 1.x (#2115) - #2116

Open
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
agent/fix-bundle-clean-assert-bundler-1x-ruby3
Open

Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
agent/fix-bundle-clean-assert-bundler-1x-ruby3

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Fixes #2115

Summary

Test-only change. The nightly e2e-extended gem leg (Ruby 3.1, Bundler 1.17.3) fails gem_vendor_fresh_checkout_bundle_install_and_revert on every run since #2081, because the step #2081 added asserts that bundle clean deletes the gem-home leftover. That Bundler cannot do so on that Ruby. No socket-patch behavior regressed, and no file under src/ changes.

Root cause

Bundler vendors its own FileUtils. Before Bundler 2.1 that copy lists a directory with a positional options hash (Dir.entries(path, {}) in 1.17.3, Dir.children(path, opts) in 2.0.2). Ruby >= 3.0 rejects the call with ArgumentError, so the directory's contents are never visited, the final rmdir fails with ENOTEMPTY, and rm_rf swallows the error. bundle clean prints Removing rack (3.2.8), exits 0 and leaves vendor/bundle/ruby/3.1.0/gems/rack-3.2.8 in place. Bundler 2.1 passes **opts and works.

The assertion never passed on this leg: the last green nightlies ran on 63f791d, before #2081.

The change

  • tests/common/bundler_e2e.rs: Bundler::clean_leaves_directories(ruby_major), true for Bundler < 2.1 on Ruby >= 3, with a unit check in the module's self-test.
  • tests/e2e_vendor_gem_build.rs: on that pair the test asserts that bundle clean named the leftover as stale, that the directory is still there (so the arm fails once the defect is gone), and that vex still reports vendored_tree_out_of_sync. It then removes the directory by hand and runs the rest of the step. Every other Bundler/Ruby pair keeps the original assertion unchanged.

Evidence

Whole suite, cargo test -p socket-patch-cli --test e2e_vendor_gem_build -- --include-ignored, with SOCKET_PATCH_BUNDLER_E2E_REQUIRED=1:

Ruby Bundler origin/main this branch
3.1.6 1.17.3 fails at e2e_vendor_gem_build.rs:787, as in the nightly 14 passed
3.1.6 2.1.4 not run 14 passed
3.3.6 4.0.18 not run 14 passed

cargo clippy --locked --workspace --all-features -- -D warnings (the CI command) is clean. cargo clippy -p socket-patch-cli --all-targets already fails on origin/main in test helpers this PR does not touch; it reports nothing on the changed lines.

PR CI runs this suite on its default Bundler only. The 1.17.3 leg runs in the nightly, so the table above is the evidence for that leg until the next nightly.

Review findings not applied

  • The Ruby major comes from ruby on PATH, not from the interpreter behind bundle. The test already builds the gem directory path from that same probe, and CI provisions both with ruby/setup-ruby, so a host where they differ fails earlier for the same reason.

Follow-up for a maintainer

On Bundler < 2.1 with Ruby >= 3, the remedy the vendored_tree_out_of_sync warning names (bundle clean) does not clear the warning. The verdict and the VEX document are unaffected. Naming a different remedy for that pair would change CLI output, so this PR leaves it alone. The test now pins the current behavior.

https://claude.ai/code/session_011f9aePEeutq9i2gda491Vn


Generated by Claude Code

Assisted-by: Claude Code:claude-fable-5-2
The nightly gem leg runs Bundler 1.17.3 on Ruby 3.1. There
bundle clean prints 'Removing rack (3.2.8)', exits 0 and leaves the
directory: the FileUtils copy Bundler vendors before 2.1 calls
Dir.entries(path, {}), Ruby >= 3.0 rejects the positional hash, and
rm_rf swallows the error. The step added with #2081 asserted the
directory was gone, so it failed on that leg every time.

The test now asserts on every Bundler that bundle clean names the
leftover as stale. On Bundler < 2.1 with Ruby >= 3.0 it checks the
directory is still there and removes it by hand, so the lock and
vex checks after it still run. Every other pair keeps the original
assertion.

Fixes #2115

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aePEeutq9i2gda491Vn
Review of the first commit: the stdout check is only needed where
bundle clean fails to delete, so it moves into that arm and the
other Bundler legs no longer depend on Bundler's wording. On the
affected pair the test now also runs vex before removing the
directory by hand and asserts vendored_tree_out_of_sync is still
reported, so the test shows what a user on that pair sees. The
helper's doc comment names the call each Bundler line makes.

Refs #2115

Assisted-by: Claude Code:claude-fable-5-2
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 17, 2026 13:41
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Changes only test helpers and e2e assertions; no production code or CLI behavior is modified.

Overview
Test-only fix for nightly e2e failures (#2115) where bundle clean is assumed to remove a stale gem-home directory on every Bundler/Ruby pair.

Adds Bundler::clean_leaves_directories, which is true for Bundler < 2.1 on Ruby ≥ 3 (known upstream bug: directory removal fails silently while cached specs are still pruned).

In the gem vendor capstone’s bundle clean step, that pair now expects Removing … stdout, the leftover directory still present, and vex to emit vendored_tree_out_of_sync; the test then removes the directory manually before asserting a clean vex result. All other version pairs still require full directory removal.

Self-test coverage documents the version matrix for this helper.

Reviewed by Cursor Bugbot for commit 71f0fce. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly: gem_vendor_fresh_checkout_bundle_install_and_revert fails under bundler 1.17.3 (bundle clean leaves rack-3.2.8)

2 participants