Repository navigation
Fix pnpm env settings read across majors (#1460) - #1461
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Hosted pnpm refused to pin a lock over environment settings the project's pnpm never reads. pnpm 10 and older read only npm_config_* variables and pnpm 11 and newer only pnpm_config_*, but socket-patch accepted both families on every major. The common trigger: `npx socket-patch scan --mode hosted` in a pnpm 11/12 project whose .npmrc still has an npm-era package-lock=false. npx exports npm_config_package_lock=, pnpm 12 ignores it and installs from the lock, yet the scan warned redirect_pnpm_lockfile_disabled and pinned nothing. The same blindness made gitBranchLockfile and sharedWorkspaceLockfile env lookups refuse or mis-route. The environment is now read in the family the project's pnpm major reads (the same major that already picks pnpm-workspace.yaml vs .npmrc), and in both families only when the major is unknown. Fixes #1460 Assisted-by: Claude Code:claude-opus-5-5
Hosted pnpm scans now look the pnpm major up for the environment fallback only when one of the candidate variables is actually set, so a project with no such variable does not re-read its lock. Also documents the per-major family for sharedWorkspaceLockfile and folds the duplicated test helpers. Refs #1460 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
|
bugbot run 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 c782837. Configure here.
|
Ready for review at
Generated by Claude Code |
Final review briefWhat it does: pnpm reads one family of environment variables per major: Risk: low to medium. The code is small and correct. For a known major, though, it moves from refusing to pinning, so it relies on the per-major claim. That claim is backed by the measured table in #1460 for pnpm 9.15.9, 10.34.6, 11.28.3 and 12.11.2, and the tests encode every cell of it. It also trusts Look here:
Verified:
Changes I made: none. Open questions (non-blocking):
Auto-merge (squash) is armed, so approving sends it straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1460
Summary
Hosted pnpm mode refused to pin a lock over environment settings the project's pnpm never reads. The common trigger is
npx socket-patch scan --mode hostedin a pnpm 11/12 project whose.npmrcstill has an npm-erapackage-lock=false. npx exportsnpm_config_package_lock=, and pnpm 12 ignores it and installs from the lock. The scan still warnedredirect_pnpm_lockfile_disabled, pinned nothing, and exited 0 withstatus: success.Root cause
env_setting(crates/socket-patch-core/src/utils/pnpm_workspace.rs) looked uppnpm_config_<key>and thennpm_config_<key>on every pnpm major. Real pnpm reads one family per major:npm_config_*on pnpm 10 and older,pnpm_config_*on pnpm 11 and newer (empirical table in #1460). This affected three settings:lockfile/package-lock(lockfile_disabled): falseredirect_pnpm_lockfile_disabledgit-branch-lockfile(view_settingviagit_branch_locks, used by both hosted and vendored): falseredirect_pnpm_git_branch_lockfile/vendor_pnpm_git_branch_lockfileshared-workspace-lockfile(view_settingviaworkspace_members): member locks routed by a variable pnpm ignoresFix
env_settingtakes the pnpm major, the samepnpm_majorthat already choosespnpm-workspace.yamlvs.npmrc. It readspnpm_config_*for 11+,npm_config_*for 10 and older, and both when the major is unknown (the safe side, same as the file rule).view_settingis now async and passes the major down. The major is only computed when a candidate variable is actually set, so scans with no such variable don't re-read the lock.CLI_CONTRACT.mdnow describes the per-major family for all three settings.Tests (red → green)
npm_config_package_lock=, plusnpm_config_lockfileon 11/12,pnpm_config_lockfileon 9/10,npm_config_git_branch_lockfileon 12,pnpm_config_git_branch_lockfileon 10; controls refuse in the family the major reads)in_process_redirect_pnpm::hosted_scan_reads_pnpm_env_settings_for_the_project_pnpm_major(spawns the CLI with the env set)pnpm@12.11.2 npm_config_package_lock=: pin count 0, expected 1pnpm_workspace::tests::the_environment_disables_the_lockfile_only_for_its_pnpm_majorpnpm_workspace::tests::the_environment_family_follows_the_pnpm_majorLocal runs:
cargo fmt --all -- --check: okcargo clippy --workspace --all-features -- -D warnings: okcargo test -p socket-patch-core --all-features --lib: 6409 passed. The 4 failures (copy_treesymlink relax,vlt_healunremovable lock,pypi_poetry/pypi_requirementswrite-failure) depend on chmod and fail only because the sandbox runs as root. None touch pnpm.cargo test -p socket-patch-cli --all-features --test in_process_redirect_pnpm --test in_process_vendor_pnpm_takeover --test hosted_memory_parity: 33 + 15 + 42 passedcargo test --workspaceran out of sandbox disk while linking ~100 CLI test binaries, so CI is the full run.No wrapper (
npm/,pypi/,gem/) changes are needed: this logic lives only in the Rust core./code-review high: findings not fixed
pnpm_config_*: false positive. 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's table shows pnpm 9.15.9 and 10.34.6 installing from the lock withpnpm_config_lockfile=falseset..npmrcgit-branch-lockfile/shared-workspace-lockfileread on pnpm 11+, env overriding a file setting, stale.modules.yamlmajor, upper-caseNPM_CONFIG_*: pre-existing behavior of the file and lookup rules, not this root cause. Left for separate issues.pnpm_majorread when no variable is set, the stalesharedWorkspaceLockfilecontract line, and the duplicated test helpers.🤖 Generated with Claude Code
https://claude.ai/code/session_01E552fKgtx93unKJDowBuF4
Note
Medium Risk
Changes when hosted/vendored pnpm runs refuse vs pin based on CI/npx-injected env vars; behavior now matches real pnpm but could differ from prior overly conservative refusals.
Overview
Fixes #1460: hosted pnpm mode no longer treats npm-era environment variables (
npm_config_*) as disabling the lockfile or enabling git-branch locks on pnpm 11+, which only honorpnpm_config_*(pnpm ≤10 still usenpm_config_*).env_settinginpnpm_workspace.rsnow picks the env var family from the project’s pnpm major (same sources as existing file-based rules). That affectslockfile_disabled,git_branch_locks, andsharedWorkspaceLockfileenv fallbacks via asyncview_setting. The major is resolved only when a relevant env var is set.CLI_CONTRACT.mddocuments the per-major behavior.Adds integration test
hosted_scan_reads_pnpm_env_settings_for_the_project_pnpm_major(e.g.npm_config_package_lock=fromnpxon pnpm 12 no longer blocks pinning) and unit tests for the env-family matrix.Reviewed by Cursor Bugbot for commit c782837. Configure here.
Generated by Claude Code