Skip to content

Hosted pnpm 11/12 scan ignores a pnpm_config_trust_lockfile=false env override and says "installs need no extra flags", but the next frozen install fails with ERR_PNPM_TARBALL_URL_MISMATCH #1514

Closed

Description

[agent] Found by the scheduled pnpm bug-hunt routine (ledger #303).

Summary

On pnpm 11 and 12, an environment setting pnpm_config_trust_lockfile=false (or PNPM_CONFIG_TRUST_LOCKFILE=false) takes precedence over the trustLockfile: true that hosted mode writes into pnpm-workspace.yaml. scan --mode hosted never reads that variable, even when it is set in the scan's own environment. It writes the key, reports success, and its redirect_pnpm_trust_lockfile warning says "commit it alongside the lock; installs need no extra flags". Every install with that environment then fails with ERR_PNPM_TARBALL_URL_MISMATCH.

npm has the same kind of setting, and socket-patch already handles it there: patch/redirect/npmrc.rs respects an explicit npm_config_allow_remote env var ("beats every file"). #1460 / #1074 taught the pnpm side to read npm_config_* / pnpm_config_* for lockfile, but not for trustLockfile.

Impact

A CI that deliberately pins trustLockfile off (for example, to keep pnpm's lockfile re-verification) gets a red install after a "successful" hosted scan. Nothing in the scan output points at the variable. pnpm's own error then tells the user to rebuild the lockfile, which silently drops the hosted patches; the warning does tell them not to do that. The failure is loud, so nothing unpatched gets attested, but the remedy the scan gives is wrong for this environment.

Repro

# Mock patch API on :18080 serving pkg:npm/left-pad@1.3.0 (batch, by-package, view, package grant,
# hosted tarball, /registry mirror), same contract as tests/e2e_redirect_pnpm_build.rs.
export SOCKET_PATCH_SERVER_URL=http://127.0.0.1:18080 SOCKET_NPM_REGISTRY=http://127.0.0.1:18080/registry
export pnpm_config_trust_lockfile=false          # set in CI and in the shell that runs the scan
mkdir proj && cd proj
echo '{"name":"root","version":"1.0.0","dependencies":{"left-pad":"1.3.0"}}' > package.json
pnpm install                                     # pnpm 12.11.2
socket-patch scan --mode hosted --json --yes --api-url http://127.0.0.1:18080 --org org --api-token x
#  status success; writes pnpm-workspace.yaml {packages: ['.'], trustLockfile: true}
#  redirect_pnpm_trust_lockfile: "... `trustLockfile: true` was written to a new pnpm-workspace.yaml —
#  commit it alongside the lock; installs need no extra flags."
mkdir ../fresh && cp package.json pnpm-lock.yaml pnpm-workspace.yaml ../fresh && cd ../fresh
pnpm install --frozen-lockfile --store-dir "$(mktemp -d)"
#  ERR_PNPM_TARBALL_URL_MISMATCH, exit 1
pnpm_config_trust_lockfile=true pnpm install --frozen-lockfile --store-dir "$(mktemp -d)"   # control: exit 0, patched

Expected vs actual

OS × version

Linux, Node 22, main 887a5f7, real pnpm, fresh copy of the committed files and an empty store for each install:

pnpm Setting Scan Fresh frozen install
10.34.6 pnpm_config_trust_lockfile=false success ok, patched (pnpm 10 doesn't verify)
11.28.3 pnpm_config_trust_lockfile=false success, "no extra flags" ERR_PNPM_TARBALL_URL_MISMATCH (2/2)
12.11.2 pnpm_config_trust_lockfile=false success, "no extra flags" ERR_PNPM_TARBALL_URL_MISMATCH (2/2)
12.11.2 PNPM_CONFIG_TRUST_LOCKFILE=false success ERR_PNPM_TARBALL_URL_MISMATCH
11.28.3 / 12.11.2 npm_config_trust_lockfile=false success ok, patched (pnpm ignores it)
11.28.3 / 12.11.2 trustLockfile: false in global $XDG_CONFIG_HOME/pnpm/config.yaml success ok, patched (the workspace file wins)

macOS and Windows weren't probed. Reading env and settings isn't OS-specific.

First bad version: none bisected. Auto-trust has never consulted the environment.

Suspect code

Activity

  1. mikolalysenko commented on Oct 14, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triage: priority:p1 (pnpm, npm family). Not a duplicate, and no open or merged PR covers it. #1460 / #1074 taught the pnpm lockfile setting to read npm_config_* / pnpm_config_* from the environment, but the trustLockfile plan still only reads pnpm-workspace.yaml. That makes this a gap next to #1460, not the same defect. Unclustered for now: the fix is to run the trust plan through the same major-aware env reader in utils/pnpm_workspace.rs and report an env false as UserSet with the variable named.


    Generated by Claude Code

  2. mikolalysenko commented on Oct 14, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue (shared root cause: the hosted pnpm trustLockfile plan reads only pnpm-workspace.yaml, never the pnpm_config_trust_lockfile env override). Branch: agent/fix-pnpm-trust-lockfile-env. Claim-ID: 2026-10-14T12:21:46Z-8bda15


    Generated by Claude Code

  3. mikolalysenko commented on Oct 14, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Draft PR: #1533


    Generated by Claude Code

  4. added a commit that references this issue on Oct 14, 2026
    3efa5b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions