Repository navigation
Fix pnpm hosted patch over a vendored dependency (#2263) - #2266
Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
Conversation
pnpm 12.23 refuses a lock in which a package fetched from a hosted patch depends on a vendored file: tarball (#2263). This empty commit opens the branch; the fix follows. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
Two legs for the registry-route suite, against a real pnpm 12: a hosted patch of peer-user and a vendored patch of its dependency leaf, in either order. The second run must be refused and change nothing, the project must still install frozen, and the hosted scan both refusals name must then patch both packages. Both legs fail on main with pnpm 12.23.0: the second run exits 0 and the frozen install then stops on ERR_PNPM_LOCAL_SUBDEP_NOT_ALLOWED (#2263). Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
pnpm 12.23 refuses a lock in which a package that is not local depends on a local file, unless it can tie the workspace override to that package. It cannot for a registry package whose resolution names a tarball URL, which is what a hosted patch leaves. pnpm writes that lock itself for the workspace file the two modes leave together and then refuses it, frozen or not, so every install of the project fails with ERR_PNPM_LOCAL_SUBDEP_NOT_ALLOWED. Whichever run comes second is now refused before anything is written: - vendoring a package is refused (vendor_lock_entry_unsupported) when a dependent of it is a registry package fetched from a tarball URL; - the hosted pin of a package is refused (redirect_pnpm_local_dependency) when it would take a package with a file: or link: dependency off the default registry. A package that already names a tarball is re-pinned as before. Fixes #2263 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
A hosted to vendored takeover judges each hosted pin against the lock as the run found it, so the dependency of a package that is still hosted is refused in the run that vendors the package, and vendored by the next run. The eject restores every pin first and moves both in one run. Two tests pin that, and the e2e legs now end with a vendored scan that can vendor the dependency but not the package: both stay hosted and the project still installs frozen. The vendored refusal names the package and its lock key, not the tarball URL, and points at the eject. CLI_CONTRACT.md and docs/ecosystems.md describe both refusals. Refs #2263 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
The check walked the packages section by hand when it was given no index, which the pnpm architecture guard counts as a new raw reader in vendor/pnpm_lock.rs. It now builds the index in that case and reads both sections through it, so the guard's count is unchanged. Refs #2263 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
Review of the first cut found the gates too wide and one too narrow: - The vendored gate refused any registry dependent whose resolution names a tarball, which is every package of a project that sets lockfileIncludeTarballUrl. It now refuses only a dependent a hosted patch pins: a tarball in a patch server's path shape. - The hosted gate treated link: like file:, and pnpm writes link: for a peer a workspace project satisfies. Only file: refuses now. - The hosted gate skipped a package whose resolution already named any tarball. It now skips only one an earlier patch already pins. - Rush's planner has its own gate list and did not call the vendored gate; it does now, with a test. - Off the index, the vendored gate scans the two sections instead of building a whole index per package; the pnpm architecture guard lists that read with its reason. - The takeover pre-pass comment said no pnpm gate reads a resolution; it now says which one does and what follows. Refs #2263 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
|
[agent] bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Hosted mode ( Vendored mode adds Takeover behavior: Reviewed by Cursor Bugbot for commit 2ee69e7. Configure here. |
|
[agent]
Generated by Claude Code |
|
[agent] PR shepherd: review brief What it does Risk Look here
Verified Changes I made Open questions
Generated by Claude Code |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2263
Summary
On pnpm 12.23.0, a project with a package patched in hosted mode and one of its dependencies patched in vendored mode can no longer install: every
pnpm install, frozen or not, stops onERR_PNPM_LOCAL_SUBDEP_NOT_ALLOWED. Bothsocket-patchruns exited 0 and told the user to commit.Now whichever run would create that pair is refused before anything is written, and the project keeps installing:
get <dependency> --mode vendoredunder a hosted packagevendor_lock_entry_unsupported, nothing writtenget <package> --mode hostedover a vendored dependencyredirect_pnpm_local_dependency, patchskipped/redirect_unconfirmed, nothing writtenscan --mode vendoredthat can vendor the dependency but not the packageBoth refusals name the remedy: one mode for the package and its dependency.
scan --mode hostedtakes a vendored dependency over.Root cause
pnpm 12.23 refuses a lock in which a package that is not local depends on a local file, unless it can tie the workspace override to that package. It can for a package on the default registry. It can't for one that a hosted patch pins (the tarball of the pin, or the named registry of the route). pnpm 12.23.0 resolves the workspace file the two modes leave to the byte-identical lock and then refuses that lock itself, so there is no lock shape to write instead: only an override with no version in its selector passes, and that would redirect every release of the dependency.
Neither side looked at what the other mode had left:
name: versionref to thefile:tarball whatever the dependent resolved from;snapshots:entry depended on.The change
vendor/pnpm_lock.rs:check_hosted_dependents, called from the pre-flight beside the other ref gate, and from the Rush planner's gate list. It refuses when a registry-keyed dependent resolves to a tarball in a patch server's path shape.formats/pnpm/hosted.rs: the planner refuses a pin that would make a hosted package of one whose snapshot has afile:dependency. The patch is refused across the whole lock set, as for the existing residual gate. A package an earlier patch already pins is re-pinned as before, so a project already in this state keeps getting its grants refreshed.CLI_CONTRACT.mdanddocs/ecosystems.mddescribe both refusals.The refusals don't depend on the pnpm version a project pins: the lock would break as soon as the project moves to 12.23.
Evidence
All real-pnpm runs used pnpm 12.23.0.
e2e_redirect_pnpm_build:pnpm12_vendored_dependency_of_a_hosted_patch_is_refused,pnpm12_hosted_patch_over_a_vendored_dependency_is_refusedpnpm_hosted.rs:a_package_with_a_local_dependency_is_not_taken_off_the_registry,the_local_dependency_refusal_is_scoped_to_the_new_pinlink:, another package's dependency, an already pinned packagevendor::pnpm_lock:hosted_dependents_refuse_vendoring_their_dependencyvendor::pnpm_lock::rush:a_dependency_of_a_hosted_package_is_refusedin_process_vendor_pnpm_parent_child: two takeover testsLocal runs after the last change:
cargo test -p socket-patch-core: all pass.cargo clippy --locked --workspace --all-features -- -D warnings(the CI command): clean.--all-targetsreports errors, all in test files this PR doesn't touch.in_process_vendor_pnpm_takeover,in_process_redirect_pnpm,in_process_pnpm_registry_cleanup,in_process_vendor_pnpm_parent_child: pass.in_process_redirect: 3 tests fail in my sandbox (partial_lockfile_write_failure_exits_1_and_writes_no_ledger,redirect_json_mode_write_failures_emit_error_envelope,vlt::scan_redirect_vlt_heal_invalidation_failure_warns). They simulate write failures through file permissions and the sandbox runs as root.e2e_redirect_pnpm_build(the sixpnpm12legs) ande2e_vendor_pnpm_build(all but the pinned matrix): pass.CI on this head:
clippyis green. The requiredci-okis red, only becausehosted-e2efails ingem_bundler_hosted_install_proof: the live patch service now selects a patch foractivestorage@6.0.3that the test's pinnedGEM_UUIDSset doesn't list. This PR doesn't touch gem code or that test.Behavior to review
A hosted to vendored takeover of a package and its dependency now takes two runs.
scan --mode vendoredover a hosteddebugand its hosted dependencymsvendorsdebug, refusesmsand exits 1; the next run vendorsms. Before, one run did both (checked by switching the gate off). The takeover pre-pass judges each pin against the lock as the run found it, wheredebugis still hosted. Exempting a dependent that the same run takes over would need the run to undo the dependency when the dependent then fails, and I left that out. Two hosted packages that depend on each other are refused on every such run.socket-patch vendor(the eject) restores every pin first and moves them in one run; the refusal says so.vendored_takeover_keeps_the_child_hosted_until_the_parent_is_vendoredandeject_vendors_a_hosted_parent_and_child_in_one_runpin both.Review findings not fixed
/code-review highran on the first cut. Fixed: the vendored gate was too wide (any tarball),link:was treated as local, the hosted gate skipped any package with a tarball, the Rush planner was not gated, the gate built a whole index when it had none, and the pre-pass comment was stale. Not fixed:Follow-ups
lockfileIncludeTarballUrl: true, pnpm 12.23.0 also refuses a vendored-only project (a registrymidwith its tarball URL in the lock, over a vendoredleaf). pnpm 12.22.0 installs the same lock. Refusing there would stop vendoring almost anything in such a project on every pnpm, so it needs a decision (a gate on the pinned pnpm version, or a different wiring) and its own issue.https://claude.ai/code/session_011f9aeTAwXzUmgdCtoh8Trm
Generated by Claude Code