Repository navigation
Description
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
After vendoring a gem in a project whose gems were already installed (every developer machine), socket-patch vex warns vendored_tree_out_of_sync for each vendored gem and tells the user to re-run the package manager's install. With Bundler that never helps: once the Gemfile points at path: ".socket/vendor/gem/...", bundle install installs nothing for the gem and leaves the old registry copy (<gem home>/gems/rack-2.2.8) where it is. Bundler doesn't load that copy any more (the app loads the vendored one), but vex keeps comparing it and keeps warning on every run.
Impact
- The vendored common path ends with a warning on the step the scan itself prescribes ("Reinstall from the updated lockfile ..., then run
socket-patch vex"), although the install is correct and the app runs the patched code. - The remedy in the message doesn't work when followed, however often
bundle installis run. The user has to guessbundle clean --force(which only applies to a project-localvendor/bundle; in a system or shared gem home there is no safe command, because other projects may use that copy). - The text says "the live tree carries different bytes", which reads as "you are running unpatched code". That is false here.
- A
--jsonconsumer gets avendored_tree_out_of_syncentry inwarnings[]on every run.
Repro
I used a local mock of the patch API with patches for rack 2.2.8 and rake 13.0.6 (no API key is available in the sandbox). Any vendorable gem patch shows it.
mkdir app && cd app
printf 'source "https://rubygems.org"\n\ngem "rack-test", "2.1.0"\ngem "rack", "~> 2.2"\ngem "rake", "~> 13.0", group: :development\n' > Gemfile
bundle config set --local path vendor/bundle
bundle install # lock resolves rack 2.2.8, rake 13.0.6
socket-patch scan --mode vendored --yes # "Vendored 2 packages."
bundle install # the step the scan prescribes
bundle exec ruby -e 'require "rack"; puts $LOADED_FEATURES.grep(/rack\/utils/)'
# .../.socket/vendor/gem/<uuid>/rack-2.2.8/lib/rack/utils.rb <- the patched copy is what loads
socket-patch vex --product pkg:generic/app@1 >/dev/null
bundle install && socket-patch vex --product pkg:generic/app@1 >/dev/null # same warning againActual
Warning: pkg:gem/rack@2.2.8: the installed tree does not match its vendored artifact; the attestation is based on the committed .socket/vendor artifact (the project's lockfile or package-manager config wires it in), but the live tree carries different bytes — re-run your package manager's install to resync it.
Warning: pkg:gem/rake@13.0.6: the installed tree does not match its vendored artifact; ... — re-run your package manager's install to resync it.
Emitted 1 VEX statement
The warning goes away only after bundle clean --force removes vendor/bundle/ruby/3.3.0/gems/rack-2.2.8 and rake-13.0.6. A fresh clone installed with BUNDLE_DEPLOYMENT=true never shows it.
Expected
CLI_CONTRACT.md describes vendored_tree_out_of_sync as "the PRESENT installed tree hash-mismatches the patched bytes — run the package manager's install", and adds a manager-specific remedy where the plain install doesn't resync (Hatch: hatch env remove <env>; PDM < 2.11: pdm sync --reinstall; #641, #700). The same file says of Bundler that after vendoring "the copies Bundler already holds are unused leftovers" ("Gem stale-install guard", What never refreshes). So for a gem whose Gemfile wires the path: source, either the leftover registry copy shouldn't count as the installed tree (Bundler loads the vendored directory), or the warning should say that the copy is an unused leftover and name a remedy that works (bundle clean for a project-local bundle path).
Versions
| Ruby | Bundler | Gem home | Result |
|---|---|---|---|
| 3.3.6 | 4.0.18 | vendor/bundle |
warns after every bundle install; clears after bundle clean --force |
| 3.1.6 | 2.6.9 | rbenv system gems | warns after every bundle install |
| 3.3.6 | 4.0.18 | fresh clone, BUNDLE_DEPLOYMENT=true |
no warning |
socket-patch main 7c5240e (5.1.0), Linux. Not platform-specific as far as I can tell. First bad release not searched.
Suspect code
crates/socket-patch-cli/src/commands/vex.rs:1329: the generic remedy text, with Hatch and PDM notes but none for Bundler.- Where
outcome.vendored_out_of_syncis filled for gems: the crawled gem-home copy is compared although the lock resolves the gem from aPATHsection.
Generated by Claude Code
Activity
bundler: 2026-11-14 run (vendored mode, monorepo, platform gems; #2075,
mikolalysenko commentedon Nov 14, 2026
[agent] Claiming this issue. Branch: agent/fix-vex-vendored-gem-leftover-copy.
Generated by Claude Code
Skip gem-home leftovers in vex's drift probe
Name a working remedy for a gem leftover in vex
Name the gem leftover and its one remedy
List every gem leftover with gem uninstall -i
Describe the gem remedies instead of a command