Skip to content

Define the settings read before switching to the pinned pnpm #144

Closed

Description

@zkochan

Found by the defect-hotspots skill (pnpm/pnpm#17021) on 2026-10-17 over 90 days of main (086165da7a). The root cause comes from reading the commits and code; it was not reproduced. The design steps are proposals for a maintainer to settle.

Loop: Pinned pnpm switch (about 17 fixes)

Property. Before handing off to the pinned pnpm, the running pnpm reads the pin and a known small set of settings and flags the same way from every entry point. It tolerates everything else, and recording the pin never fails the command.

Members. pnpm/pnpm#14838, pnpm/pnpm#16360, pnpm/pnpm#16362, pnpm/pnpm#16437, pnpm/pnpm#16469, pnpm/pnpm#16479, pnpm/pnpm#16498, pnpm/pnpm#16564, pnpm/pnpm#16587, pnpm/pnpm#16597, pnpm/pnpm#16648, pnpm/pnpm#16676, pnpm/pnpm#16785, pnpm/pnpm#16826, pnpm/pnpm#16919, pnpm/pnpm#17003, pnpm/pnpm#16405. Earlier members of the same loop: pnpm/pnpm#14457, pnpm/pnpm#14468, pnpm/pnpm#14531, pnpm/pnpm#14626, pnpm/pnpm#14637, pnpm/pnpm#14641, pnpm/pnpm#14753, pnpm/pnpm#15206, pnpm/pnpm#16280, pnpm/pnpm#16601. Parity drift still open: pnpm/pnpm#16319 (trustPolicy).

Flaw.

  • The pre-switch pass loads the full config under the running pnpm's schema: load_pre_command_config and v11 loadConfigOrSwitchToPinnedPnpm. Nothing defines which settings it may honor, so failures were patched with retry paths (unreadable_settings.rs, skip_unreadable_settings, switchPastUnreadableConfig).
  • Three switch-input builders with hand-written flag allowlists: from_cli_args, --version, and the unparsed argv scan.
  • A separate pin reader in self-update, project_pins_pnpm. It probably misses package.yaml and workspace-root pins; this is unverified.
  • Every command records the pin, so --version and run inherit install's failure modes.

Design change.

  1. An explicit BootstrapSettings field list, loaded leniently per key. Strict validation runs after the decision to continue.
  2. One argv reader with a flag table derived from clap.
  3. One pin locator.
  4. Record the pin only for install-family commands. This needs a maintainer decision.
  5. A v11 mirror, which also settles Project trustPolicy is applied when switching to the packageManager pnpm version pnpm#16319.

Tests.

  • Equivalence across the three input builders over generated argvs.
  • A coverage test that classifies every global clap arg as bootstrap or after-switch.
  • A nightly cross-version matrix: outer pnpm {11.latest, oldest 12.x, 12.latest, HEAD} × pin {10, 11, HEAD via local pnpr} × setting source × platform. Current tests only run HEAD switching down, never an older outer pnpm with a newer project.

The shared test harnesses that cover this loop and the others are tracked in #141.


Written by an agent (Claude Code, claude-opus-5-5).

Activity

  1. self-assigned this
    on Oct 17, 2026
  2. zkochan commented on Oct 17, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17026 does step 3, "One pin locator". PinRoots is now the only pin locator, and the pre-command pass and pnpm self-update both use it. That fixes a real bug: self-update read only package.json in --dir. So it missed the workspace root's pin when run in a workspace package, and missed pins in package.yaml or package.json5. pnpm v11 already got this right.

    This only covers part of the issue. Still open: BootstrapSettings (step 1), the unified argv reader (step 2), recording the pin only for install-family commands (step 4, needs a maintainer decision), the v11 mirror and pnpm/pnpm#16319 (step 5), and the proposed tests.


    Written by an agent (Claude Code, claude-opus-5-5).

  3. zkochan commented on Oct 17, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17035 does step 2, "One argv reader with a flag table derived from clap". The --version scan and the scan of a rejected command line now read their flags through BootstrapArgv, a clap struct that flattens the same groups the parsed path reads. It also adds the two tests the issue proposes: one checks that the three readers agree on generated argvs, and one makes every global clap flag declare whether it is read before the switch or after it.

    Still open: BootstrapSettings (step 1), recording the pin only for install-family commands (step 4, needs a maintainer decision), the v11 mirror with pnpm/pnpm#16319 (step 5), and the nightly cross-version matrix.


    Written by an agent (Claude Code, claude-opus-5-5).

  4. zkochan commented on Oct 17, 2026

    @zkochan
    MemberAuthor

    Maintainer decisions on the two open items:

    Still open: step 1, BootstrapSettings (an explicit list of settings loaded leniently per key before the switch), and the nightly cross-version matrix, which #141 tracks.


    Written by an agent (Claude Code, claude-opus-5-5).

  5. zkochan commented on Oct 17, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17045 does step 1. The pass reads settings in tiers. It reads none when no candidate manifest pins pnpm or a runtime. It reads only PIN_DECISION_SETTINGS to decide. It reads every setting this pnpm can read only to switch or to record the pin. Strict validation and the config warnings move to the command's own load. The retry path is gone.

    With that, every step of this issue is done or decided against (step 4). The nightly cross-version matrix is tracked in #141. Possible v11 follow-up: v11 likely has the same --version failure on an unreadable setting under a satisfied pin. It's unverified and noted in the PR.


    Written by an agent (Claude Code, claude-opus-5-5).

  6. zkochan commented on Oct 17, 2026

    @zkochan
    MemberAuthor

    pnpm/pnpm#17045 (merged) covers step 1 for pnpm v12.

    The v11 --version follow-up is now verified and open as pnpm/pnpm#17049. In v11, pnpm --version exited 1 when the global config.yaml could not be parsed, even under a pin the running pnpm satisfied. With the PR, a failed load on a bare --version falls back to the settings pnpm can read, and the existing pin handling decides from them.

    Once that merges, every step here is done or decided against. The nightly cross-version matrix stays with #141.


    Written by an agent (Claude Code, claude-opus-5-5).

  7. zkochan commented on Oct 17, 2026

    @zkochan
    MemberAuthor

    Done. Every step here has landed or was decided against:

    The nightly cross-version matrix stays with #141.


    Written by an agent (Claude Code, claude-opus-5-5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions