Repository navigation
Fix pnpm trustLockfile env override ignored (#1514) - #1533
Merged
Mikola Lysenko (mikolalysenko) merged 4 commits intoOct 14, 2026
Merged
Conversation
Assisted-by: Claude Code:claude-opus-5-5
pnpm 11 and 12 read pnpm_config_trust_lockfile (or its uppercase spelling) ahead of pnpm-workspace.yaml. With it set to false, a hosted scan still wrote trustLockfile: true there and said installs need no extra flags, so every install in that environment failed with ERR_PNPM_TARBALL_URL_MISMATCH. The scan now treats a non-true value of that variable as an explicit user setting, like trustLockfile: false in the file: on a project whose pnpm is 11 or newer (or unknown) it writes nothing and the trust warning names the variable and the remedies (unset it or set it to true for installs, or use --mode vendored). The in-memory engine sees no environment and is unchanged. Fixes #1514 Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
Review follow-ups for the trustLockfile env override: - The trust check now reads the project's pnpm major through the same helper as the lockfile setting (#1460) instead of a second copy, and the env reader reuses the existing variable lookup. - A project pinned to pnpm 9.0-10.4, or with a keyless workspace file that lists members, keeps its more specific guidance; the override only replaces the generic write. - A workspace member scanned with the override set is no longer refused with advice to add trustLockfile: true to the root file, which the variable would override anyway; the scan pins the member lock and its warning names the variable. Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 14, 2026 13:21
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 2dc1100. Configure here.
Tanmay Singla (Tanmay182003)
approved these changes
Oct 14, 2026
Collaborator
Author
|
Final reviewer: sent to the merge queue (squash). Approved by Tanmay Singla (@Tanmay182003) on the current head 2dc1100, Generated by Claude Code |
5 tasks
Mikola Lysenko (mikolalysenko)
deleted the
agent/fix-pnpm-trust-lockfile-env
branch
October 14, 2026 13:59
This was referenced Oct 14, 2026
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 #1514
Summary
On pnpm 11 and 12, a
pnpm_config_trust_lockfile(orPNPM_CONFIG_TRUST_LOCKFILE) environment variable takes precedence over thetrustLockfile: truethat hosted mode writes intopnpm-workspace.yaml. If that variable wasfalse,scan --mode hostedstill wrote the key and reported "installs need no extra flags", and then every install in that environment failed withERR_PNPM_TARBALL_URL_MISMATCH.The scan now treats a non-true value of that variable as an explicit user setting, the same way it treats
trustLockfile: falsein the file and the way the npm arm treatsnpm_config_allow_remote. It writes nothing. Theredirect_pnpm_trust_lockfilewarning names the variable and gives the remedies: unset it, set it totruewherever the project installs, or re-run with--mode vendored.Root cause
The trust plan in
pnpm_trust(crates/socket-patch-core/src/hosted/engine.rs) chose between write,AlreadyTrueandUserSetby looking only at the text ofpnpm-workspace.yaml. It never read the environment that pnpm 11+ reads ahead of that file.Changes
utils/pnpm_workspace.rs: newtrust_lockfile_env(major, env). It returns the override only for pnpm 11 and newer, or when the major is unknown. pnpm 10 never verifies lock URLs, and no pnpm readsnpm_config_trust_lockfile. The variable lookup goes through the existingenv_setting. The pnpm-major heuristic is now one sync helper,pnpm_major_from, shared with the Hosted pnpm scan refuses with redirect_pnpm_lockfile_disabled over env lockfile settings the project's pnpm major ignores (e.g. any pnpm 11/12 project run throughnpm execwith package-lock=false) #1460 lockfile check.hosted/engine.rs: newRewriteOptions::pnpm_env, an injected environment lookup. The CLI passes the process env. The in-memory engine passes none, since it sees no install environment.pnpm_trustrespects an override in both the root-workspace branch and the member-lock branch (Hosted scan from a pnpm 11/12 workspace member with its own lock writes trustLockfile into a nested member pnpm-workspace.yaml that pnpm ignores, so the root install fails with ERR_PNPM_TARBALL_URL_MISMATCH #880). The more specific pnpm 9.0–10.4 pin and keyless-members guidance still comes first.scan/hosted.rs: the member pre-check (redirect_pnpm_settings_elsewhere) no longer refuses with advice to addtrustLockfile: trueto the root file when the environment overrides that key. In that case the engine pins the member lock and reports the variable.CLI_CONTRACT.md(pnpm trust contract) anddocs/ecosystems.md.Test evidence
hosted::engine::tests::issue_1514_a_trust_lockfile_env_override_is_respected(lowercase and uppercase variable, existingtrustLockfile: true, member lock; controls:true, npm spelling, pnpm 10 pin)["pnpm-lock.yaml", "pnpm-workspace.yaml"]writtenutils::pnpm_workspace::tests::the_environment_sets_trust_lockfile_only_for_pnpm_11_and_newere2e_redirect_pnpm_build::pnpm11_trust_lockfile_env_override_is_respected(real pnpm 11.28.5,SOCKET_PATCH_PNPM_E2E_REQUIRED=1)rewrittenFiles: ["pnpm-workspace.yaml"], "installs need no extra flags"Run locally:
cargo fmt --all -- --check: okcargo clippy --workspace --all-features -- -D warnings: okcargo test -p socket-patch-core --all-features --lib: 6484 passed. 4 failed, all of them read-only-permission tests (copy_tree::relax_loop_must_not_traverse_symlinked_root,vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry,pypi_poetry::wire_write_failure_maps_error_and_leaves_lock_untouched,pypi_requirements::wire_failure_rolls_back_already_written_files). They can't fail as root, which is how the sandbox runs, and they are unrelated to this diff.cargo test -p socket-patch-cli --all-features --lib --bins: 920 passede2e_redirect_pnpm_build -- --ignored pnpm11_: 4 passedcargo test --workspacebuild ran out of sandbox disk while linking the CLI integration binaries. CI covers those.npm/,pypi/,gem/) changes are needed: this is engine-only.Review findings not fixed (/code-review high)
pnpm_config_trust_lockfile=0coercion. The value is read with the repo's existing env convention (PnpmSetting::as_bool, the npm-config reader: only''/false/null/undefinedare false), the same as every other pnpm env setting here. Changing that convention for one key would make them disagree.pnpm_config_trust_lockfile=falseenv override and says "installs need no extra flags", but the next frozen install fails with ERR_PNPM_TARBALL_URL_MISMATCH #1514 verified thatPNPM_CONFIG_TRUST_LOCKFILE=falsemakes pnpm 12.11.2 fail on Linux, so it is honoured.npm_config_allow_remoteprecedent (CLI_CONTRACT), and the warning says plainly that nothing was written and why.std::envinview_setting. The injection keeps the engine testable and lets the in-memory engine opt out. Movinglockfile/gitBranchLockfileonto it is a separate refactor.🤖 Generated with Claude Code
https://claude.ai/code/session_018Vu8yCCshtPxwd4jscWRAU
Generated by Claude Code