Skip to content

Hosted to vendored switch of a gem fails with "no installed package found on disk" once a newer patch is published, though the gem is installed and --dry-run previews success #2129

Closed

Description

[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).

Summary

A Bundler project has a gem on a hosted patch, and the installed copy holds that patch's bytes (the hosted scan's own install refresh, or a bundle install after it). Socket then publishes a newer patch (new uuid) for the same gem version. scan --mode vendored now fails for that gem with

Error: Cannot vendor pkg:gem/rack@3.2.8: no installed package found on disk
Vendored 0 packages; 1 not installed.

and exits 1. The gem is installed (vendor/bundle/ruby/3.3.0/gems/rack-3.2.8), and scan --mode vendored --dry-run on the same tree previews success (would fix CVE-…). This is the gem form of #1105 (uv), which #1713 fixed for PyPI.

Impact

  • The switch from hosted to vendored mode is blocked for every gem whose patch was superseded, and the project stays on the old patch. On a project with several patched gems the run vendors the others and exits 1, so CI fails on a half-switched (but installable) pair.
  • The message sends the user the wrong way: the gem is installed, so bundle install changes nothing and the re-run fails the same way. Nothing names the way out (below).
  • --dry-run and the real run disagree.
  • A gem with a native extension gets the same "no installed package found on disk" in place of the real, documented reason (native_extensions_unsupported). With the patch not superseded the same gem reports "puma-8.1.2.gemspec declares native extensions; bundler does not build extensions for path-sourced gems".

No file is damaged: for the failed gem the Gemfile and Gemfile.lock keep the old hosted pin and the install still works.

Repro

Needs a patch API that can serve two patches for one gem version in turn. The bug-hunt mock does (ledger #316, harness notes): patch v1 for rack 3.2.8 under uuid A, then swapped to patch v2 under uuid B on the same URL.

mkdir app && cd app
printf 'source "https://rubygems.org"\n\ngem "rack", "~> 3.2.0"\n' > Gemfile
printf '**/vendor/bundle/\n' > .gitignore
bundle config set --local path vendor/bundle
bundle lock && bundle install           # resolves rack 3.2.8
git init -q . && git add -A && git commit -qm init

# patch v1 (uuid A) is the current patch
socket-patch scan --mode hosted         # pins rack to .../patch-registry/gem/<token>/<A>/ and
                                        # replaces the installed copy with the patched build
git add -A && git commit -qm hosted

# the service now answers with patch v2 (uuid B) for pkg:gem/rack@3.2.8
socket-patch scan --mode vendored --dry-run   # "pkg:gem/rack@3.2.8: would fix CVE-…"
socket-patch scan --mode vendored             # Error: Cannot vendor pkg:gem/rack@3.2.8:
                                              # no installed package found on disk   (exit 1)
ls vendor/bundle/ruby/*/gems                  # rack-3.2.8 is there

--json reports {"action":"skipped","purl":"pkg:gem/rack@3.2.8","errorCode":"package_not_installed","reason":"no installed package found on disk"}.

What does work on the same project:

  • With patch v1 still current, scan --mode vendored takes the gem over from hosted (the documented takeover).
  • On a checkout with no gems installed (vendor/bundle absent), scan --mode vendored vendors patch v2: the pristine gem is fetched.
  • scan --mode hosted first (moves the pin to uuid B and refreshes the installed copy), then scan --mode vendored: vendors patch v2, and the app loads it after bundle install.
  • A gem that is already vendored on patch v1 re-vendors to v2 (with "installed content differs from patch baseline; the patched content will be vendored").

Expected

docs/ecosystems.md, "Ruby gems: gems already installed": "Vendoring a gem that was hosted (vendor, scan --mode vendored) leaves the installed copies as they are: Bundler loads the vendored copy from then on." Nothing limits that to the patch uuid the hosted pin names. The scan should vendor the newer patch, as it does for a lock-only checkout and as PyPI does since #1713, or at least refuse with the real cause and the remedy (re-run scan --mode hosted first). --dry-run should preview what the real run does.

Actual

package_not_installed / "no installed package found on disk", exit 1, the gem stays on the old hosted patch.

Versions

socket-patch Bundler Ruby Result
main 89c482d (5.1.0) 4.0.18 (lock with CHECKSUMS) 3.3.6 fails (3 runs: rack alone; rack and puma beside thor)
main 89c482d (5.1.0) 2.5.22 (lock without CHECKSUMS) 3.3.6 fails
main 89c482d either, no gems installed 3.3.6 vendors the new patch
main 89c482d either, patch not superseded 3.3.6 takeover works

Linux only. Nothing here depends on the platform, so macOS and Windows should behave the same. First bad release not searched for.

Suspect code

crates/socket-patch-cli/src/commands/vendor.rs:4351 is where the purl falls out as "unmatched": the installed copy holds patch v1's bytes, which match neither the before nor the after hashes of patch v2, and unlike the lock-only case no pristine gem is fetched because a copy is on disk. gem_takeover_refusals_for (vendor.rs:1669) and the dry-run preview do not see this. #1713 is the PyPI fix for the same shape.


Generated by Claude Code

Activity

  1. mikolalysenko commented on Nov 18, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue. Branch: agent/fix-gem-takeover-superseded-hosted-patch.


    Generated by Claude Code

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:triagedbugSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentpm:bundlerBundler (RubyGems)priority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions