Repository navigation
Hosted gem rollback / remove leave the patched .gem in the project's committed vendor/cache, so every later bundle install fails with mismatched checksums (exit 37) while the unwind reports success #1260
Description
Activity
- addedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:bundlerBundler (RubyGems)Bundler (RubyGems)
on Oct 9, 2026 - added a commit that references this issue
on Oct 9, 2026 mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actions[agent] Triage:
priority:p1(Bundler). Not a duplicate. #1109 and #1098 cover the scan side, which flags a stale system gem-home copy. This issue is about the unwind side:rollback/removeleave a patched archive in Bundler's cache dir. No open or merged PR addresses it, andrestoreinpatch/redirect/upstream/gem.rsonmainstill rewrites only Gemfile + Gemfile.lock.
Generated by Claude Code
mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actions[agent] Claiming this issue (shared root cause: the hosted gem unwind restores Gemfile + Gemfile.lock but never checks Bundler's cache dir for the patched archive). Branch: agent/fix-gem-unwind-stale-cache. Claim-ID: 2026-10-09T11:22:03Z-5ccfee
Generated by Claude Code
mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actions- added 7 commits that reference this issue
on Oct 9, 2026 - addedv5-blockerMust resolve before v5: public interface/migration or ordinary patch-install-undo failure.Must resolve before v5: public interface/migration or ordinary patch-install-undo failure.uxCLI commands, help, diagnostics, output consistency, or actionable recovery instructions.CLI commands, help, diagnostics, output consistency, or actionable recovery instructions.compatibilityPublic CLI/JSON, saved state, upgrades, or package-manager compatibility.Public CLI/JSON, saved state, upgrades, or package-manager compatibility.
on Oct 9, 2026 mikolalysenko commented
on Oct 9, 2026 CollaboratorAuthorMore actionsv5 release blocker (P1). Routine Bundler rollback with committed vendor/cache must give an effective cache/reinstall remedy so the next bundle install works. PR #1263 is pending.
This follows the maintainer's release scope: one normally completing CLI instance, prioritizing valid-lockfile patch/install behavior, compatibility, and actionable CLI UX.
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
In hosted mode, a project that commits its gem cache (
bundle cache/bundle package, sovendor/cacheor a configuredcache_path) ends up with the patched.gemarchive in that cache.rollbackandremoverestoreGemfile+Gemfile.lockto the rubygems.org entry, re-pinCHECKSUMSto the upstream sha, and reportstatus: success. They leave the cached archive alone and don't mention it. Bundler installs from the cache first and checks it against the restored upstream checksum, so every laterbundle installfails, frozen or not:(exit 37)
rollbackemits only the genericreinstall_requiredadvisory ("installed trees keep their patched bytes until the next package-manager install"), which implies the next install fixes things. Here the next install can't run at all.removeemits no warning. On Bundler 2.5 (noCHECKSUMS), a frozen / deployment install takes the cached archive without complaint, so the project keeps installing the patched bytes after a "successful" rollback, while an unfrozen install fails with exit 37.The forward direction already handles this exact artifact:
scan --mode hostedflags a stale archive in the cache dir withredirect_gem_stale_installand tells the user to delete it (#483). The unwind has no counterpart.Impact
BUNDLE_FROZEN/ deployment) and local installs fail until someone finds and deletesvendor/cache/<gem>-<ver>.gemby hand. Bundler's own suggested remedy ("remove the matching checksum in Gemfile.lock and runbundle install") doesn't help: it still fails against the remote checksum.Repro (Linux, Ruby 3.3.6; local mock of the patch API + patch-registry compact index, real rubygems.org upstream)
Expected vs actual
reinstall_requiredrow says installed trees are fixed "until the next package-manager install".status: success, and the patched archive stays in the cache dir. Every install exits 37 on Bundler ≥ 2.6 (and 2.5 unfrozen). Bundler 2.5 frozen installs keep the patched gem.Matrix (all reproduce; each cell ×1 unless noted)
rollback(×2)vendor/cacheremovevendor/cacherollbackcache_path gems/cacherollbackvendor/cacherollbackvendor/cachebundle install)rollbackvendor/cacherollback, no cache (control)rollback, cached archive deleted (control)vendor/cachemacOS / Windows not probed. The behaviour is OS-independent (lock text and a cache file).
Suspect code
crates/socket-patch-core/src/patch/redirect/upstream/gem.rs:596(restore) rewrites only the manifest + lock and never looks at Bundler's cache dir.crates/socket-patch-cli/src/commands/rollback.rs:1497emits only the genericreinstall_required. The cache-dir resolution already exists for the scan-side guard (crates/socket-patch-cli/src/commands/scan/hosted.rs:237, the vendor/cache flavor ofredirect_gem_stale_install, which honourscache_pathsince Fix Bundler settings resolution order (#483, #507) #532) and could feed a matching warning, or a deletion, on unwind.Not bisected: hosted gem unwind was added in v5 and has never touched the cache.