Fix vendored pnpm shadowing workspace overrides (#360) - #785
Open
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Open
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
On pnpm 10.5+ a project can keep its overrides in pnpm-workspace.yaml. Vendoring still wrote a package.json pnpm.overrides copy, which pnpm 10 uses in place of the workspace overrides. Frozen installs then failed with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and a re-lock silently dropped the user's overrides. When the lock already records a user override from the workspace file and package.json has none of its own, vendoring now wires only the workspace file and the lock. pnpm 9 and 10.0-10.4 never record workspace overrides, so they keep the package.json copy as before. Fixes #360 Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 4, 2026 14:07
Collaborator
Author
|
BugBot review Generated by Claude Code |
The previous commit ran rustfmt over the whole workspace, which reformatted 130 files the fix never touched. Restore them to main so the PR only carries the pnpm override change and its tests. Assisted-by: Claude Code:claude-opus-5-5
Collaborator
Author
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit eb4ddc6. Configure here.
Collaborator
Author
|
[burn-down agent] Ready for review at
Generated by Claude Code |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #360
Summary
With a lockfile 9.0 project on pnpm 10.5+ that keeps its
overrides:inpnpm-workspace.yaml,vendor/scan --mode vendoredno longer adds apackage.jsonpnpm.overridescopy. That copy replaced the user's workspace overrides on pnpm 10. Before this change,vendorreported success, but everypnpm install --frozen-lockfilethen failed withERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and a re-lock silently dropped the user's overrides. Now only the workspace file and the lock are wired.The diff is 2 files (
vendor/pnpm_lock.rsandtests/e2e_vendor_pnpm_build.rs). An earlier commit on this branch reformatted the whole workspace with rustfmt by mistake. The second commit,eb4ddc6, reverts all 130 unrelated files tomain.Root cause
The vendored pnpm 9.0 writer (
vendor_pnpm_dialect) always calledapply_pkg_override. That function writes a back-compatpackage.jsonpnpm.overridesentry for pnpm versions that read overrides only frompackage.json. On pnpm 10.5–10.x, apackage.jsonpnpm.overridesfield takes the place of the workspace-fileoverrides:instead of merging with them. The lock socket-patch wrote (the user's overrides plus ours) then no longer matched the override set pnpm computes (ours only).Fix
New helper
workspace_overrides_govern. It returns true only when all three hold:package.jsonhas nopnpm.overridesof its own;pnpm-workspace.yamlhas a blockoverrides:section with a user-authored (non-vendored) key;overrides:section records that key.The third condition is direct evidence that the pnpm which wrote this lock reads the workspace file. pnpm 9 and 10.0–10.4 ignore workspace overrides and never record them, so on those versions the
package.jsoncopy is still written, as before.When the helper returns true, the
package.jsonstep is skipped: no write and nopnpm_pkg_overridewiring record. Revert, rollback and the in-sync re-run all follow the wiring records, so they need no change. The legacy (pnpm 7/8) dialect is untouched.Test evidence
Each regression test failed before the fix and passes with it.
vendor::pnpm_lock::tests::workspace_read_overrides_skip_the_package_json_copypnpm.overridese2e_vendor_pnpm_build::pnpm_vendor_keeps_user_workspace_overrides_authoritative(real pnpm 10.34.6)pnpm.overridesWhat the e2e test does:
overrides: {is-number: 7.0.0}and vendors left-pad.package.jsonis byte-identical after vendoring.pnpm install --frozen-lockfilewith an empty store. It asserts the install succeeds, installs the patched left-pad bytes, and still resolves is-odd's is-number to 7.0.0, so the user's override holds.vendor --revertand assertspackage.json,pnpm-workspace.yamlandpnpm-lock.yamlare restored byte for byte.These control tests pass, showing the existing behavior is kept:
workspace_overrides_unrecorded_in_lock_keep_the_package_json_copy: pnpm 9 / 10.0–10.4 locks still get the copy.existing_package_json_overrides_keep_the_package_json_copyCommands run locally:
cargo clippy --workspace --all-features -- -D warnings: clean.cargo fmt: the changed hunks are rustfmt-formatted.cargo fmt --all -- --checkis not clean onmainitself (about 130 files), and CI runs no fmt check.cargo test --workspace --all-features --no-fail-fast: 9728 passed, 12 failed. All 12 are pre-existing permission-based write/remove-failure tests (e.g.vendor_state_write_failure_reports_failed_eventuseschmod 0o555). They can't fail as intended in this sandbox because it runs as root, and none touch pnpm. CI runs as non-root and is green.cargo test -p socket-patch-cli --all-features --test e2e_vendor_pnpm_build: 17 passed (1 ignored), re-run oneb4ddc6.cargo test -p socket-patch-core --lib -- vendor::pnpm: 201 passed, re-run oneb4ddc6.pnpm_pinned_matrix_vendored_lifecycle_and_manifestless_vexwithSOCKET_PATCH_PNPM_E2E_VERSION=10.28.0: ok.npm/,pypi/orgem/changes are needed).CI on
eb4ddc6: all 8 Actions workflows that run for these paths passed (CI, pnpm, npm, Bun, vlt, Composer, Benchmarks, Audit GHA Workflows), and Bugbot found no issues.Generated by Claude Code