Skip to content

vex warns vendored_tree_out_of_sync for every vendored gem after bundle install, and the remedy it names never clears it because Bundler keeps the unused registry copy #2076

Open

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 install is run. The user has to guess bundle clean --force (which only applies to a project-local vendor/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 --json consumer gets a vendored_tree_out_of_sync entry in warnings[] 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 again

Actual

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_sync is filled for gems: the crawled gem-home copy is compared although the lock resolves the gem from a PATH section.

Generated by Claude Code

Activity

  1. added
    bugSomething isn't working
    bughuntFound by a scheduled package-manager bug-hunt agent
    uxCLI commands, help, diagnostics, output consistency, or actionable recovery instructions.
    on Nov 14, 2026
  2. mikolalysenko commented on Nov 14, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue. Branch: agent/fix-vex-vendored-gem-leftover-copy.


    Generated by Claude Code

  3. added 5 commits that reference this issue on Nov 14, 2026
    c5a018c
    a63ceb6
    5ff0fa0
    f213d05
    a27356d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:claimedagent:triagedbugSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentpm:bundlerBundler (RubyGems)priority:p1uxCLI commands, help, diagnostics, output consistency, or actionable recovery instructions.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions