Agent to vendored switch of a PyPI package or gem fails with "no installed package found on disk" once a newer patch is published, though the copy is installed and --dry-run previews success
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 55/100
Piste de recherche
Start with CandidateGates::judge in crates/socket-patch-cli/src/commands/vendor.rs and read the superseded_install and hosted_gem_install helpers. Then inspect tests/scan_vendor_e2e.rs and the three named unit tests in the issue; reproduce the PyPI and gem agent-to-vendored cases with the fixtures described. Done means a single recorded package vendors despite mismatched installed bytes, while ambiguous multiple variants still report a matching-variant problem.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
[agent] Found by the architecture refactor routine (ledger discussion #2244, lead L36), on main at cfc870f.
Problem
scan --mode vendored, get --mode vendored and vendor refuse a PyPI package or a gem whose installed copy holds the patched file at bytes that are neither side of the patch, and they report it as a package that is not installed:
$ socket-patch scan --mode vendored --yes
1 package has a newer patch available.
pkg:pypi/[email protected]: installed content differs from patch baseline; the patched content will be vendored
Vendored 0 packages; 1 not installed.
Error: Cannot vendor pkg:pypi/[email protected]: no installed package found on disk (exit 1)
The run reads the installed copy, says the patched content will be vendored, vendors nothing, and then says no installed package was found.
The usual way into that state is a project in agent mode whose patch has since been superseded. The virtualenv (or the gem directory) holds the older patch's output, which is neither the pristine file nor the newer patch's output. So the switch from agent mode to vendored mode fails for every PyPI package and gem with a newer patch published. This is the agent-mode sibling of #2129 (hosted gem), #1105 (hosted uv) and #769 (vendored Pipenv), which each fixed one cause of the same message.
Who it hurts
- The switch to vendored mode exits 1 and the package stays on the older patch. Beside other patched packages the run vendors those and exits 1, so CI fails on a half-switched project.
- The message sends the user the wrong way. The package is installed, so
pip installorbundle installchanges nothing and the next run fails the same way. --dry-runon the same tree previews success ([dry-run] Would download and vendor 1 patch).- Any other installed copy at other bytes gets the same report: a locally edited file, or another build of the version.
No file is damaged. The requirement line, the manifest and the installed copy stay as they were.
Evidence on main
All runs use the binary built from cfc870f (cargo build -p socket-patch-cli), a file-only project, a local stand-in for the patch API, and the repository's prebuilt-artifact fixture (tests/prebuilt_common) as the vendor service.
Agent mode on an older patch, then vendored. requirements.txt holds six==1.16.0. The virtualenv's six.py holds the output of patch A, which the manifest records. The API now offers patch B for pkg:pypi/[email protected].
$ socket-patch apply --check --offline
Patches are in sync (1 patch checked).
$ socket-patch scan --mode vendored --yes --dry-run
1 package has a newer patch available.
[dry-run] Would download and vendor 1 patch. No changes made.
HIGH [email protected] CVE-2024-0001 (exit 0)
$ socket-patch scan --mode vendored --yes
1 package has a newer patch available.
pkg:pypi/[email protected]: installed content differs from patch baseline; the patched content will be vendored
Vendored 0 packages; 1 not installed.
1 vulnerability left to patch: 1 is in packages this run did not patch.
Error: Cannot vendor pkg:pypi/[email protected]: no installed package found on disk (exit 1)
Under --json the event is {"action":"skipped","purl":"pkg:pypi/[email protected]","reason":"no installed package found on disk","errorCode":"package_not_installed","details":{"mode":"vendored"}}, with status: "partialFailure".
scan --mode agent first (it moves the copy to patch B in place) and then scan --mode vendored works. Nothing in the output names that way out.
The same package in four installed states, one patch, no newer one:
Installed six.py |
vendor |
vendor --force |
scan --mode vendored |
|---|---|---|---|
| the pristine file | vendored | vendored | vendored |
| the patch's own output | vendored | vendored | vendored |
| other bytes | exit 1, "no installed package found on disk" | vendored | exit 1, the two lines above |
| no copy anywhere | vendored | vendored | vendored |
A gem (Gemfile.lock with demo-gem (1.0.0), the copy under vendor/bundle/ruby/3.4.0/gems/, its lib/demo_gem.rb at other bytes):
$ socket-patch scan --mode vendored --yes
pkg:gem/[email protected]: installed content differs from patch baseline; the patched content will be vendored
Vendored 0 packages; 1 not installed.
Error: Cannot vendor pkg:gem/[email protected]: no installed package found on disk (exit 1)
$ socket-patch get pkg:gem/[email protected] --mode vendored --yes
Vendored 0 packages; 1 not installed.
Error: Cannot vendor pkg:gem/[email protected]: no installed package found on disk (exit 1)
$ socket-patch vendor --force
Vendored 1 package. (exit 0)
npm, for comparison (node_modules/left-pad/index.js at other bytes):
$ socket-patch scan --mode vendored --yes
pkg:npm/[email protected]: installed content differs from patch baseline; the patched content will be vendored
Vendored 2 packages. (exit 0)
Two recorded variants of one release (?artifact_id= records), the installed copy matching neither: both are skipped / package_not_installed / "no installed package found on disk". With nothing installed the same two are vendor_variant_ambiguous, which says what is wrong.
Cause
CandidateGates::judge in crates/socket-patch-cli/src/commands/vendor.rs (line 3283) runs the installed-variant probe for PyPI and gems: it hashes one patched file of the installed copy against the record (line 3313). The probe exists to choose among several release variants of one version. When the file matches neither hash the candidate is dropped (CandidateVerdict::Skip, line 3328), even when it is the only record for the package and there is nothing to choose. The dropped purl then falls into the unmatched list, whose report is "no installed package found on disk" (line 4688).
Three earlier fixes each let one cause of a failed probe through, by name:
| Fix | Cause it lets through | Where |
|---|---|---|
| #825 for #769 | the vendor ledger records the package at an older uuid | superseded_install, line 3158 |
| #1713 for #1105 | a PyPI package the lockfiles pin hosted | superseded_install |
| #2143 for #2129 | a gem the lockfiles pin hosted | hosted_gem_install, line 3182 |
An agent-mode patch, an edit and another build are not on that list. apply got its own honest report for an installed copy that matches no record in #2237 (no_matching_variant); the vendor path was not part of that change.
What settles the expected behavior
CLI_CONTRACT.md, thevendor --forcerow: "vendoring commits the patch server's verified artifact and never reads the installed files' content, so a missing or mismatched installed file vendors the same with or without--force(no warning)". Here the two differ.- The scan's own line, "the patched content will be vendored", and
scan_vendor_annotates_mismatched_baseline_and_vendors_anyway(tests/scan_vendor_e2e.rs, line 1625), which pins that outcome for npm. --dry-runpreviews the vendoring.- Every other ecosystem, and PyPI and gems for the three causes above, already vendor.
Planned fix
- One record for the package: vendor it, whatever the installed copy holds. PyPI takes the stand-in source that
superseded_installalready selects, and a gem keeps its installed directory ashosted_gem_installdoes (the backend reads only its name and gemspec, to refuse a platform gem or a native extension). The two helpers lose their lists of causes. - Several recorded variants and the installed copy matches none: keep the skip, since nothing can choose among them, and stop calling it not installed. The text names the copy and the file that differs, as
applydoes. - Tests: the agent-to-vendored switch onto a newer patch for PyPI and for a gem, through
scan --mode vendored, failing onmain. Three unit tests pin today's narrower rule and change with the fix:hosted_pin_marks_a_pypi_install_superseded(line 5866),hosted_pin_keeps_a_gem_install_as_the_source(line 5886) and the first assertion ofjudge_sends_a_hosted_gem_on_from_its_installed_dir(line 5900).
One open point, for step 2 only: whether that event keeps the code package_not_installed or takes apply's no_matching_variant. The first slice keeps the code and changes the text.
Not checked
- Real
pipand Bundler installs: the fixtures are files only. - A gem with a native extension or a platform gem in this state (#2129 reports that the same message replaces
native_extensions_unsupportedthere). - macOS and Windows. Nothing here depends on the platform.
- One more way into the state, seen once and with synthetic hashes: a project with no virtualenv on a machine whose own Python holds the same version of the package. The probe then judges the machine's copy.
Generated by Claude Code
- Langage dominant
- Rust
- Étoiles
- 9
- Forks
- 2
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 313
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p2
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
SocketDev/socket-patch#2306 ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit bug priority:p3
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
SocketDev/socket-patch#2296 ·
Les mainteneurs répondent en général sous 1 jour
-
agent:needs-human agent:triaged ci-janitor priority:p1
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
SocketDev/socket-patch#2270 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit bug priority:p1
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
SocketDev/socket-patch#2259 ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit priority:p3 refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
SocketDev/socket-patch#1860 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de SocketDev/socket-patch
Issues similaires
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 63/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
obi1kenobi/cargo-semver-checks#1839 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`Peut-être pris @iliqiliev l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ajeetdsouza/zoxide#1381 ·
Les mainteneurs répondent en général sous 5 jours
-
triage
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
kornia/kornia-rs#1416 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours