Skip to content

fix(install): refuse a modules dir linked from another store on add - #17264

Merged
zkochan merged 9 commits into
mainfrom
fix-unexpected-store-error
Oct 24, 2026
Merged

zkochan merged 9 commits into
mainfrom
fix-unexpected-store-error

Conversation

@zkochan

@zkochan zkochan commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Before this PR, pnpm v12's pnpm add, pnpm remove, and pnpm update silently purged and reinstalled node_modules when .modules.yaml recorded a different store, virtual store directory, or layout version. pnpm v11 fails these commands with ERR_PNPM_UNEXPECTED_STORE, ERR_PNPM_UNEXPECTED_VIRTUAL_STORE, or ERR_PNPM_MODULES_BREAKING_CHANGE (validateModules and checkCompatibility in pnpm11/installing/deps-installer/src/install/), and only a plain pnpm install purges. This PR ports those checks to v12 and makes pnpm update a non-plain install, as installsOnly is in v11.

The errors tell the user to run pnpm install, but in both CLIs the optimistic repeat install answered "Already up to date": the workspace state recorded neither storeDir nor virtualStoreDir. This PR fixes that in both stacks, so the documented recovery works.

This changes behavior for v12 users who relied on the silent reinstall. It restores v11 behavior, so it ships as a fix, and the v12 changeset says so. The v11 half has its own changeset because its release note differs.

Part of pnpm/tasks#191

Notes for review:

  • Recorded values. Both stacks record each configured setting as the directory the installer resolves it to, with the store version appended to storeDir. In v11 that is storeDir against the workspace directory (else the project), as createStoreController does, and virtualStoreDir against the lockfile directory. Relative and absolute spellings therefore compare equal. A verification-triggered install passes the store as an absolute path, and TS CI caught the first, as-spelled version on that. A setting that is not configured stays unset, so the check needs no store placement and reads no extra file.
  • pnpm run / pnpm exec verification ignores both settings and carries the recorded values forward, as it does for dev/optional/production. A script runs the same from whichever store node_modules was linked from. This also keeps a deployed project passing verification (deploy.ts in v11, deploy::deployed_project_passes_dependency_verification in v12) without deploy-specific code. A pnpm install inside a deploy directory whose config names another store now reinstalls.
  • No purge outside a plain install. v11 purges only for a plain install (forceNewModules = installsOnly), so its add after a nodeLinker change keeps node_modules and writes a .modules.yaml with the new linker. The old layout's packages then stay forever (v11: pnpm add after a nodeLinker change leaves the old layout's packages in node_modules tasks#203). Purging there is no better: a filtered add relinks only the selected projects, and an unreadable .modules.yaml gives no record of what pnpm owns. v12 add, remove, and update therefore fail on that drift too, with a new ERR_PNPM_NODE_LINKER_DIFF (documented in pnpm/docs/errors.md) or ERR_PNPM_MODULES_BREAKING_CHANGE for an unreadable .modules.yaml. The layout-drift check compares the recorded store and virtual store with the same lexical comparison the errors use, case-insensitive on Windows with full Unicode folding, as path.relative does.
  • Global virtual store. Under GVS, v12 records the configured virtualStoreDir anchored at the lockfile directory, as v11 does, not the global virtual store.
  • One-time install after upgrading. Projects that set storeDir or virtualStoreDir run one full install (no purge) after upgrading, because older states lack the keys.
  • v11 option mutation. createStoreController writes the resolved store into the options it gets, and so does the recursive install context. installDeps now passes a copy, and the recursive state write snapshots the configured value. Otherwise an unconfigured store would be recorded as the default store's path.
  • Layout version is not recorded. It has been 5 since 2021, before the workspace state existed (2024), so only a hand-edited .modules.yaml can disagree with it.
  • confirmModulesPurge stays v11-only, as v12 lists it.
  • ERR_PNPM_MODULES_BREAKING_CHANGE now uses the default reporter's title and help, like the other two errors.
  • @pnpm/workspace.state gains a dependency on @pnpm/constants for the store version.

Squash Commit Body

pnpm v12 let `pnpm add`, `pnpm remove`, and `pnpm update` silently purge
and reinstall `node_modules` when `.modules.yaml` recorded a different
store, virtual store directory, or layout version. Its port of
`validateModules` carried only the hoist-pattern and
`virtualStoreDirMaxLength` checks, and `pnpm update` ran as a plain
install, so it skipped even those.

pnpm v11 (`validateModules` and `checkCompatibility` in
pnpm11/installing/deps-installer/src/install/) fails every mutation
other than a plain install with ERR_PNPM_MODULES_BREAKING_CHANGE,
ERR_PNPM_UNEXPECTED_STORE, or ERR_PNPM_UNEXPECTED_VIRTUAL_STORE, and only
`pnpm install` takes the purge path. `installsOnly` is false for an
install with `update` set, so `pnpm update` errors too.

`check_modules_settings_diff` now runs the `checkCompatibility` checks
after the `*_DIFF` ones, in v11's order. Paths compare lexically,
case-insensitively on Windows, like `path.relative`, and the
neighbouring `v3` store is accepted as v11 does. The hoist-pattern
checks skip a `virtualStoreOnly` manifest, as v11 does. The error text
and help match v11's default reporter. `pnpm update` now passes
`installs_only: false`. A mutation other than a plain install never
purges. It also fails on a `nodeLinker` change
(ERR_PNPM_NODE_LINKER_DIFF) and on an unreadable `.modules.yaml`
(ERR_PNPM_MODULES_BREAKING_CHANGE). v11 keeps the tree there and records
the new linker, which leaves the old layout's packages behind for good
(pnpm/tasks#203). Purging would drop links a filtered mutation does not
recreate. The layout-drift check compares the store paths the way the
errors do.

The errors tell the user to run `pnpm install`, but in both CLIs the
optimistic repeat install reported "Already up to date" because the
workspace state recorded neither `storeDir` nor `virtualStoreDir`. Both
stacks now record the configured values and compare them like the other
settings, so that install purges and recreates `node_modules`. The fast
path reads no extra file.

Each configured setting is recorded as the directory the installer
resolves it to, with the store version appended to `storeDir`, so a
relative and an absolute spelling compare equal. In v11 `storeDir`
resolves against the workspace directory, else the project, as the store
controller does, and `virtualStoreDir` against the lockfile directory. An
unconfigured setting stays unset. Under a global virtual store, v12
records the configured `virtualStoreDir`, not the global store. `pnpm run` and `pnpm exec` verification
ignore both settings and carry the recorded ones forward, as they do for
the dependency groups, which also keeps a deployed project passing it.
v11's store controller writes the resolved store into the options it is
given, so `installDeps` passes it a copy, and the recursive install
snapshots the value before its context does the same.

The layout version is not recorded: it has been 5 since before the
workspace state existed, so only a hand-edited `.modules.yaml` can
disagree with it. The confirmModulesPurge prompt stays v11-only.

The modules_dir_compatibility e2e module covers add, remove, and update
against a changed `storeDir`, add against a changed `virtualStoreDir`
and layout version, and the plain `pnpm install` that then recreates the
tree. installing/commands/test/storeLocationChange.ts covers the same
flow in v11, that an unchanged repeat install stays on the fast path,
and that single-project and recursive installs, and a project with its
own lockfile inside a workspace, record the configured `storeDir`.

Part of pnpm/tasks#191.

Checklist

  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version. (The new error is v12 only, since v11 already has it. The reinstall fix is in both.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note. (Two: pacquet, and @pnpm/workspace.state + @pnpm/deps.status + @pnpm/exec.commands + @pnpm/installing.commands + pnpm.)
  • Added or updated tests. Verified by sabotage:
    • Without the nodeLinker refusal, add_refuses_a_modules_dir_installed_with_another_node_linker fails.
    • Resolving a relative storeDir against the lockfile directory makes the v11 project-lockfile test record project-1/store/v11 and fail.
    • With the v12 compatibility check disabled, all three Rust tests fail.
    • With installs_only: true restored for update, the update case fails.
    • With the v12 store-location drift check disabled, the two reinstall tests fail.
    • The GVS recording test fails against the previous commit.
    • With storeDir/virtualStoreDir removed from the run ignore list, the new run-after-store-change test fails in both stacks.
    • With the previous commit, the three TS CI failures reproduce locally from a checkout outside $HOME, and they pass with this one.
    • With the v11 setting keys removed, all four v11 tests fail.
    • Without the v11 options copy, all four v11 tests fail; without the recursive snapshot, the recursive test fails.
  • Updated the documentation if needed. (ERR_PNPM_UNEXPECTED_STORE in both docs trees already says pnpm install reinstalls, which is now true.)

Local runs:

  • Rust: full pnpm-cli, pnpm-package-manager, and pnpm-workspace-state suites, plus clippy and dylint on the touched crates.
  • v11: @pnpm/installing.commands (all 43 suites), @pnpm/deps.status, and @pnpm/workspace.state.
  • v11 e2e, from a checkout outside $HOME: test/verifyDepsBeforeRun, test/deploy.ts, test/install/misc.ts, and test/install/global.ts pass. test/install/pacquet.ts fails locally only, on a warning about a v12 setting in my global config.yaml.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • pnpm install now recreates node_modules when the configured store or virtual store location changes, rather than reporting that everything is up to date.
    • pnpm add, pnpm remove, and pnpm update now report errors when node_modules is incompatible with the configured store, virtual store, layout version, or nodeLinker. Existing dependencies are preserved; run pnpm install to recreate the modules directory.
    • pnpm update also reports errors when hoist patterns or the virtual store maximum path length differ.
    • Running scripts after a store location change no longer triggers an outdated-dependencies warning solely because of that change.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between c33c58e and 96d3785.

📒 Files selected for processing: 1
  • .changeset/refuse-modules-dir-from-another-store.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The changes record configured store and virtual-store paths in workspace state, adjust dependency freshness checks, and validate existing modules directories against current settings. Tests cover location changes, install recovery, and command behavior.

Changes: Store-location behavior

Layer / File(s) Summary
Resolve and record store locations
pnpm/crates/workspace-state/src/lib.rs, pnpm/crates/package-manager/src/install/workspace_state/*, pnpm11/workspace/state/*, pnpm11/installing/commands/src/*, pnpm11/deps/status/src/*, pnpm11/installing/commands/test/*
Workspace state now includes resolved store and virtual-store paths. State writers resolve those paths against configured base directories. Tests cover path resolution and recorded state.
Check store-location drift
pnpm/crates/package-manager/src/optimistic_repeat_install/*, pnpm11/deps/status/src/*, pnpm11/exec/commands/src/runDepsStatusCheck.ts, pnpm11/pnpm/test/verifyDepsBeforeRun/*, .changeset/reinstall-after-store-location-change.md
Dependency freshness checks include store-location settings. Run checks ignore changes to those settings. Tests cover running scripts with a different store and installing after a location change.
Validate modules-directory compatibility
pnpm/crates/package-manager/src/install/errors.rs, pnpm/crates/package-manager/src/install/modules_state/*, pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs, pnpm/crates/package-manager/src/update/install.rs, pnpm/crates/cli/tests/suite/*, pnpm/crates/config/src/*, pnpm/crates/package-manager/src/install/tests/store.rs, pnpm/docs/errors.md, .changeset/refuse-modules-dir-from-another-store.md
Compatibility checks report errors for unsupported layout versions and changed store, virtual-store, hoist-pattern, or virtual-store-length settings. Tests cover command behavior, dependency preservation, and install recovery. Documentation and release notes describe the errors and behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant InstallCommand
  participant WorkspaceStateUpdate
  participant StoreLocationResolver
  participant WorkspaceState
  InstallCommand->>WorkspaceStateUpdate: configured store settings and base directories
  WorkspaceStateUpdate->>StoreLocationResolver: resolve configured locations
  StoreLocationResolver-->>WorkspaceStateUpdate: resolved store and virtual-store paths
  WorkspaceStateUpdate->>WorkspaceState: record resolved settings
Loading

Possibly related PRs

  • pnpm/pnpm#17268: Documents migration guidance for the compatibility errors and install recovery behavior implemented here.

Suggested labels: product: pnpm@11, product: pacquet

Merge Risk: ⚪ Minimal · up to 96d37

No actionable merge-blocking risk remains in the reviewed change.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                    pr
-----                                            ----                                    --
lockfile/parse_pnpm_lock                         1.00     19.4±3.09ms    19.3 MB/sec     1.01     19.5±3.05ms    19.2 MB/sec
packument/parse                                  1.00     53.2±2.78µs  1246.3 MB/sec     1.13     59.9±7.72µs  1106.9 MB/sec
tarball/download_dependency                      1.00  1257.2±319.50µs     3.4 MB/sec    1.40  1754.1±330.90µs     2.4 MB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   297.4±39.41ms 53.8 KElem/sec     1.15   342.1±11.01ms 46.8 KElem/sec
version_pick/repeated_ranges_file                1.00      5.7±0.48ms  5.5 KElem/sec     1.03      5.8±0.56ms  5.3 KElem/sec
version_pick/repeated_ranges_raw                 1.00      5.3±0.35ms  5.9 KElem/sec     1.18      6.3±0.46ms  5.0 KElem/sec
workspace_resolution/hoist_heavy                 1.00    366.2±7.10ms        ? ?/sec     1.41   516.3±83.55ms        ? ?/sec
workspace_sort/chained_projects                  1.00     21.1±3.42ms        ? ?/sec     1.38     29.1±6.81ms        ? ?/sec

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2776.85 ms 2812.44 ms 1.3% 138.84 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1523.35 ms 1557.10 ms 2.2% 76.17 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 614.54 ms 450.87 ms -26.6% 30.73 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 520.00 ms 526.73 ms 1.3% 26.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 15.41 ms 16.20 ms 5.1% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 12.94 ms 13.63 ms 5.4% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 11.08 ms 11.18 ms 0.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 10.33 ms 11.01 ms 6.6% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 3136.47 ms 3156.73 ms 0.6% 156.82 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1583.16 ms 1640.16 ms 3.6% 79.16 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 548.15 ms 768.76 ms 40.2% 27.41 ms Inconclusive (not reproduced)
isolated-fresh-install-hot-cache-hot-store pnpr 390.42 ms 457.01 ms 17.1% 19.52 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-hot-store pacquet 2074.35 ms 2417.16 ms 16.5% 103.72 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-hot-store pnpr 449.99 ms 517.32 ms 15.0% 22.50 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pacquet 290.41 ms 306.61 ms 5.6% 14.52 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 128.06 ms 106.68 ms -16.7% 6.40 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 413.52 ms 349.03 ms -15.6% 20.68 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 162.92 ms 167.06 ms 2.5% 8.15 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 97.37 ms 93.72 ms -3.7% 4.87 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 5157.39 ms 5112.50 ms -0.9% 257.87 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 5585.45 ms 5369.36 ms -3.9% 279.27 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 161.85 ms 159.50 ms -1.5% 8.09 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 198.67 ms 196.17 ms -1.3% 9.93 ms Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1374.14 ms 1483.46 ms 8.0% 68.71 ms Inconclusive (overlapping samples)
cargo-repeat-install-hot-cache-hot-store pacquet 88.73 ms 62.21 ms -29.9% 4.44 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 96d378572e88

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked, injected, and Cargo workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.815 ± 0.098 2.700 3.048 1.81 ± 0.16
pacquet@main 2.769 ± 0.082 2.624 2.870 1.78 ± 0.15
pnpr@HEAD 1.601 ± 0.152 1.437 1.873 1.03 ± 0.13
pnpr@main 1.558 ± 0.123 1.412 1.759 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.8146112603,
      "stddev": 0.0984882558270576,
      "median": 2.8124420692000003,
      "user": 3.1464420800000004,
      "system": 2.39971254,
      "min": 2.7001730867,
      "max": 3.0481086907
    },
    {
      "command": "pacquet@main",
      "mean": 2.7690322346,
      "stddev": 0.08205025329492605,
      "median": 2.7768492082,
      "user": 3.1117203799999995,
      "system": 2.29258304,
      "min": 2.6242817397,
      "max": 2.8700666527
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6014941389999997,
      "stddev": 0.15232509402756875,
      "median": 1.5570950686999998,
      "user": 2.6311308799999997,
      "system": 2.18024784,
      "min": 1.4370048656999999,
      "max": 1.8733027127
    },
    {
      "command": "pnpr@main",
      "mean": 1.5578760055,
      "stddev": 0.1225181791186895,
      "median": 1.5233495261999999,
      "user": 2.4301569799999996,
      "system": 1.9755530399999999,
      "min": 1.4116170487,
      "max": 1.7590586727
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 446.5 ± 50.4 372.0 535.0 1.00
pacquet@main 604.7 ± 78.0 510.6 728.8 1.35 ± 0.23
pnpr@HEAD 512.2 ± 42.7 455.8 569.4 1.15 ± 0.16
pnpr@main 551.9 ± 107.4 436.9 777.3 1.24 ± 0.28
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.4464840531400001,
      "stddev": 0.05040446373993394,
      "median": 0.45087370224,
      "user": 0.52407596,
      "system": 0.8946517799999999,
      "min": 0.37201234524000004,
      "max": 0.5349579552400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.60471646934,
      "stddev": 0.07799708362745214,
      "median": 0.6145423612400001,
      "user": 0.67236186,
      "system": 1.0441342800000002,
      "min": 0.5106452792400001,
      "max": 0.7287717632400001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.5122044020400001,
      "stddev": 0.0427463443671565,
      "median": 0.5267347467400001,
      "user": 0.5787815599999999,
      "system": 0.9208412800000001,
      "min": 0.45578989824000005,
      "max": 0.56944575224
    },
    {
      "command": "pnpr@main",
      "mean": 0.5518910576400001,
      "stddev": 0.10739402160300948,
      "median": 0.5199967192400001,
      "user": 0.6108612599999999,
      "system": 1.0050585799999996,
      "min": 0.43689938524000005,
      "max": 0.7773168502400001
    }
  ]
}

Scenario: Isolated linker: repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 16.7 ± 2.8 11.7 24.2 1.27 ± 0.25
pacquet@main 15.9 ± 2.6 11.1 26.7 1.21 ± 0.24
pnpr@HEAD 13.5 ± 1.6 10.2 18.5 1.03 ± 0.16
pnpr@main 13.1 ± 1.4 10.6 18.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.016667408797777776,
      "stddev": 0.0027837462131216767,
      "median": 0.01619858502,
      "user": 0.008800483456790123,
      "system": 0.009139434567901235,
      "min": 0.01172655602,
      "max": 0.02418998202
    },
    {
      "command": "pacquet@main",
      "mean": 0.01585678041735099,
      "stddev": 0.0026330534386611723,
      "median": 0.015407563020000003,
      "user": 0.0089350140397351,
      "system": 0.0082837761589404,
      "min": 0.011107404020000001,
      "max": 0.02667542702
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.013540997332138741,
      "stddev": 0.0015963317729836206,
      "median": 0.01363161602,
      "user": 0.007701703815028903,
      "system": 0.0070377722543352615,
      "min": 0.010159351020000002,
      "max": 0.01845771002
    },
    {
      "command": "pnpr@main",
      "mean": 0.013084526651067963,
      "stddev": 0.0013541063980308443,
      "median": 0.01293791402,
      "user": 0.007336411262135924,
      "system": 0.0068671368932038835,
      "min": 0.010570908020000002,
      "max": 0.01866981002
    }
  ]
}

Scenario: Isolated linker: repeat install, cold cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.4 ± 1.2 9.0 18.8 1.08 ± 0.16
pacquet@main 11.3 ± 1.2 9.2 16.1 1.07 ± 0.16
pnpr@HEAD 11.2 ± 1.2 9.1 16.5 1.06 ± 0.16
pnpr@main 10.6 ± 1.1 8.7 16.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.011385713581581927,
      "stddev": 0.0012498575261532792,
      "median": 0.011175983220000001,
      "user": 0.006712874463276838,
      "system": 0.005669315254237289,
      "min": 0.00897309022,
      "max": 0.01876638422
    },
    {
      "command": "pacquet@main",
      "mean": 0.011271546641800946,
      "stddev": 0.001241217930022397,
      "median": 0.01108454122,
      "user": 0.006703220568720377,
      "system": 0.005536115639810425,
      "min": 0.009170410220000001,
      "max": 0.01607371822
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.011226921566733663,
      "stddev": 0.0011873583300371512,
      "median": 0.011013468220000001,
      "user": 0.006881853567839199,
      "system": 0.005308381909547733,
      "min": 0.00909266522,
      "max": 0.016547529220000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.010569647536513767,
      "stddev": 0.0011026414082725108,
      "median": 0.010332212220000001,
      "user": 0.005517401467889905,
      "system": 0.00598179449541284,
      "min": 0.008745061220000001,
      "max": 0.016005880220000004
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.204 ± 0.207 2.947 3.540 1.93 ± 0.21
pacquet@main 3.181 ± 0.292 2.866 3.809 1.92 ± 0.24
pnpr@HEAD 1.671 ± 0.140 1.470 1.861 1.01 ± 0.12
pnpr@main 1.657 ± 0.145 1.461 1.888 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.20414830272,
      "stddev": 0.20704521603575227,
      "median": 3.15672882912,
      "user": 3.9428987799999993,
      "system": 2.65555822,
      "min": 2.94678151112,
      "max": 3.54010405912
    },
    {
      "command": "pacquet@main",
      "mean": 3.1806532060199997,
      "stddev": 0.2915899091059277,
      "median": 3.13646654212,
      "user": 3.8244847799999997,
      "system": 2.69200872,
      "min": 2.86629417412,
      "max": 3.80908873512
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6713506558200002,
      "stddev": 0.14011583084125148,
      "median": 1.64016205162,
      "user": 2.21673208,
      "system": 1.80494142,
      "min": 1.4699959401200002,
      "max": 1.86143347712
    },
    {
      "command": "pnpr@main",
      "mean": 1.6574313338200004,
      "stddev": 0.1451200959801197,
      "median": 1.58316102412,
      "user": 2.3388406799999997,
      "system": 1.9927518199999998,
      "min": 1.4609971291200001,
      "max": 1.88809170212
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 770.0 ± 114.8 560.5 922.4 1.93 ± 0.37
pacquet@main 549.3 ± 33.6 483.6 599.7 1.37 ± 0.19
pnpr@HEAD 480.2 ± 104.0 327.3 634.4 1.20 ± 0.30
pnpr@main 399.8 ± 50.1 336.8 505.1 1.00

Confirmation (reversed target order)

Command Mean [ms] Min [ms] Max [ms] Relative
pnpr@main 648.3 ± 108.8 464.1 871.0 1.08 ± 0.23
pnpr@HEAD 601.7 ± 75.2 465.1 703.5 1.00
pacquet@main 959.7 ± 133.4 762.0 1164.6 1.59 ± 0.30
pacquet@HEAD 787.2 ± 47.2 698.0 852.4 1.31 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7699806845399999,
      "stddev": 0.11477079688781955,
      "median": 0.7687556524400001,
      "user": 1.11110726,
      "system": 1.11464694,
      "min": 0.56045621944,
      "max": 0.92238093844
    },
    {
      "command": "pacquet@main",
      "mean": 0.54932081564,
      "stddev": 0.03357978799867797,
      "median": 0.54814787044,
      "user": 0.7776512600000001,
      "system": 0.9272416399999999,
      "min": 0.48364376944000004,
      "max": 0.59974432244
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.48022276754000004,
      "stddev": 0.10403002519957247,
      "median": 0.45701318794,
      "user": 0.47610746,
      "system": 0.84619614,
      "min": 0.32730354544,
      "max": 0.6343604124400001
    },
    {
      "command": "pnpr@main",
      "mean": 0.3998342998400001,
      "stddev": 0.05006961312019995,
      "median": 0.39041738544000004,
      "user": 0.37920126,
      "system": 0.75245604,
      "min": 0.33683097044,
      "max": 0.50506356544
    }
  ],
  "confirmation": {
    "results": [
      {
        "command": "pnpr@main",
        "mean": 0.6482777186,
        "stddev": 0.10878485048321171,
        "median": 0.6527900269000001,
        "user": 0.57512202,
        "system": 0.9469101600000001,
        "min": 0.4641301519,
        "max": 0.8710237509000001
      },
      {
        "command": "pnpr@HEAD",
        "mean": 0.6017470892000001,
        "stddev": 0.07517233974173845,
        "median": 0.5839819239,
        "user": 0.54113672,
        "system": 0.9024430599999999,
        "min": 0.4651359829,
        "max": 0.7034585309000001
      },
      {
        "command": "pacquet@main",
        "mean": 0.9596636096000001,
        "stddev": 0.13342936738430014,
        "median": 0.9829061089000001,
        "user": 1.2828645200000002,
        "system": 1.23057186,
        "min": 0.7620147929000001,
        "max": 1.1646044389
      },
      {
        "command": "pacquet@HEAD",
        "mean": 0.7871892412,
        "stddev": 0.04719712032767096,
        "median": 0.7888106699000001,
        "user": 1.15850802,
        "system": 1.12013586,
        "min": 0.6980349679000001,
        "max": 0.8524313149000001
      }
    ]
  }
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.422 ± 0.269 2.158 3.088 5.28 ± 0.76
pacquet@main 2.086 ± 0.058 2.013 2.220 4.55 ± 0.43
pnpr@HEAD 0.563 ± 0.115 0.476 0.864 1.23 ± 0.27
pnpr@main 0.459 ± 0.042 0.412 0.539 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4223062946800002,
      "stddev": 0.2694430004820813,
      "median": 2.41716097558,
      "user": 1.96933992,
      "system": 1.6284842400000001,
      "min": 2.1581295975800003,
      "max": 3.08796754358
    },
    {
      "command": "pacquet@main",
      "mean": 2.0860114232799996,
      "stddev": 0.058365288614862745,
      "median": 2.07435032308,
      "user": 1.65741922,
      "system": 1.3711042399999998,
      "min": 2.01266789758,
      "max": 2.22047638458
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.56338688358,
      "stddev": 0.11450410493208053,
      "median": 0.5173218850800001,
      "user": 0.5350088199999999,
      "system": 0.9139873399999999,
      "min": 0.47552705558,
      "max": 0.8636399075800001
    },
    {
      "command": "pnpr@main",
      "mean": 0.45888324238000006,
      "stddev": 0.041609462445583216,
      "median": 0.44998969358000007,
      "user": 0.44335201999999985,
      "system": 0.8359818400000002,
      "min": 0.41173611558000006,
      "max": 0.5394391215800001
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 313.8 ± 25.1 283.6 357.9 2.95 ± 0.27
pacquet@main 293.8 ± 13.2 275.6 317.9 2.76 ± 0.18
pnpr@HEAD 106.4 ± 5.0 96.8 115.8 1.00
pnpr@main 125.5 ± 22.6 97.5 178.8 1.18 ± 0.22
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.31383766418,
      "stddev": 0.025143298076238885,
      "median": 0.30661257288,
      "user": 0.31243402,
      "system": 0.13251398,
      "min": 0.28361232888,
      "max": 0.35786253488
    },
    {
      "command": "pacquet@main",
      "mean": 0.29378138128,
      "stddev": 0.013198880249112623,
      "median": 0.29040749438,
      "user": 0.29488472,
      "system": 0.11544147999999999,
      "min": 0.27563613888,
      "max": 0.31788406088
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10639985491703705,
      "stddev": 0.005030891970135189,
      "median": 0.10668373188000001,
      "user": 0.04655689777777777,
      "system": 0.01836329111111111,
      "min": 0.09678492088000001,
      "max": 0.11583122588000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.12549932345692308,
      "stddev": 0.022634961902252046,
      "median": 0.12805912687999998,
      "user": 0.059925812307692304,
      "system": 0.02296640384615384,
      "min": 0.09751622988000001,
      "max": 0.17875020688
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 356.4 ± 15.3 340.3 382.0 1.00
pacquet@main 398.2 ± 34.9 347.7 437.1 1.12 ± 0.11
pnpm@HEAD 6232.3 ± 692.1 5607.0 7622.0 17.49 ± 2.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35635857622444445,
      "stddev": 0.015289598870288546,
      "median": 0.34902588178000005,
      "user": 0.3756875022222222,
      "system": 0.08839497777777779,
      "min": 0.34026578478,
      "max": 0.38197759078000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.39815231333555556,
      "stddev": 0.034884669692264655,
      "median": 0.41352213578,
      "user": 0.42945716888888885,
      "system": 0.08563764444444445,
      "min": 0.34766533178000003,
      "max": 0.43712000778000004
    },
    {
      "command": "pnpm@HEAD",
      "mean": 6.232274441113335,
      "stddev": 0.69214755867207,
      "median": 6.04051618478,
      "user": 9.781182057777777,
      "system": 0.6118103111111111,
      "min": 5.60695800878,
      "max": 7.622009070780001
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 168.8 ± 13.9 140.7 189.7 1.00 ± 0.12
pacquet@main 168.0 ± 15.0 149.0 193.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.16878104375578948,
      "stddev": 0.013853000601858883,
      "median": 0.16705826744000002,
      "user": 0.1555840536842105,
      "system": 0.0795135094736842,
      "min": 0.14067667444,
      "max": 0.18966636844
    },
    {
      "command": "pacquet@main",
      "mean": 0.167989304065,
      "stddev": 0.014967904156628995,
      "median": 0.16292459594000003,
      "user": 0.15483658,
      "system": 0.08241203250000001,
      "min": 0.14895978844000002,
      "max": 0.19319813844
    }
  ]
}

Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 96.1 ± 5.6 86.6 113.1 1.00
pacquet@main 98.6 ± 5.7 92.0 117.8 1.03 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.09614968432625003,
      "stddev": 0.005581427992531691,
      "median": 0.09372257692,
      "user": 0.03702958,
      "system": 0.06662121625,
      "min": 0.08655399842,
      "max": 0.11307751542000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.09863553372000002,
      "stddev": 0.005681184265164791,
      "median": 0.09736811892,
      "user": 0.038372046666666666,
      "system": 0.06804959333333334,
      "min": 0.09196994242,
      "max": 0.11777584342
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 5.091 ± 0.202 4.719 5.364 1.00
pacquet@main 5.150 ± 0.293 4.722 5.789 1.01 ± 0.07
pnpr@HEAD 5.423 ± 1.052 4.156 7.110 1.07 ± 0.21
pnpr@main 5.640 ± 0.666 4.798 6.614 1.11 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 5.09124346606,
      "stddev": 0.20244054892606747,
      "median": 5.11249524516,
      "user": 3.3604824199999994,
      "system": 2.5306881399999996,
      "min": 4.71875626716,
      "max": 5.36372798616
    },
    {
      "command": "pacquet@main",
      "mean": 5.14971338496,
      "stddev": 0.29327055584430484,
      "median": 5.15739144166,
      "user": 3.32525032,
      "system": 2.44703084,
      "min": 4.72245090916,
      "max": 5.78886987116
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.42295431576,
      "stddev": 1.0523081813232258,
      "median": 5.36935750966,
      "user": 3.7221869199999995,
      "system": 3.1048806399999997,
      "min": 4.15648130716,
      "max": 7.1097685871600005
    },
    {
      "command": "pnpr@main",
      "mean": 5.640153401159999,
      "stddev": 0.6656365042213673,
      "median": 5.585448469659999,
      "user": 3.6704732199999994,
      "system": 2.98759944,
      "min": 4.79824821216,
      "max": 6.61427404816
    }
  ]
}

Scenario: GVS linker: fresh restore, hot cache + hot store

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 160.8 ± 8.7 151.2 175.2 1.00
pacquet@main 169.0 ± 15.8 145.9 194.1 1.05 ± 0.11
pnpr@HEAD 197.5 ± 10.6 179.3 214.6 1.23 ± 0.09
pnpr@main 199.8 ± 10.3 188.0 223.2 1.24 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.16083083305999998,
      "stddev": 0.008681201385152555,
      "median": 0.15949675306,
      "user": 0.19178466857142856,
      "system": 0.15382892,
      "min": 0.15120666706,
      "max": 0.17520058406
    },
    {
      "command": "pacquet@main",
      "mean": 0.16897107817764703,
      "stddev": 0.01577802992914314,
      "median": 0.16184612806,
      "user": 0.21786247529411767,
      "system": 0.14173324352941177,
      "min": 0.14589244506,
      "max": 0.19406903506
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.19750483464333335,
      "stddev": 0.010621359890315391,
      "median": 0.19616804856,
      "user": 0.23817774,
      "system": 0.15604483666666666,
      "min": 0.17930829306,
      "max": 0.21462512606
    },
    {
      "command": "pnpr@main",
      "mean": 0.19981064821384617,
      "stddev": 0.010276518794455972,
      "median": 0.19867434106,
      "user": 0.2449905476923077,
      "system": 0.16194395846153847,
      "min": 0.18797627706,
      "max": 0.22321520906
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.499 ± 0.135 1.359 1.813 1.09 ± 0.10
pacquet@main 1.376 ± 0.044 1.320 1.436 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4988464561400003,
      "stddev": 0.1353359526807103,
      "median": 1.48345801414,
      "user": 0.9939010400000001,
      "system": 0.33667625999999995,
      "min": 1.3590050456400002,
      "max": 1.8129230946400001
    },
    {
      "command": "pacquet@main",
      "mean": 1.3761483821400002,
      "stddev": 0.043945006485067356,
      "median": 1.3741380001400003,
      "user": 0.8192457400000001,
      "system": 0.30999726,
      "min": 1.32048880464,
      "max": 1.4361226256400001
    }
  ]
}

Scenario: Cargo: repeat install, hot cache + hot store

Frozen repeat install of a Cargo workspace (cargo.enabled: true) whose crates are already materialized in <storeDir>/v11/crates/ and linked into .pnpm/crates/crates-io. Direct installs only.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 66.9 ± 14.2 45.6 110.6 1.00
pacquet@main 91.8 ± 13.8 66.1 134.0 1.37 ± 0.36
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.06694644990000002,
      "stddev": 0.014191607702068648,
      "median": 0.06221216586000001,
      "user": 0.0440427,
      "system": 0.037431519999999996,
      "min": 0.045611441860000004,
      "max": 0.11055084686000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.0918053043957143,
      "stddev": 0.013847144458005587,
      "median": 0.08872581436000002,
      "user": 0.05088506857142857,
      "system": 0.052436878571428584,
      "min": 0.06614578286,
      "max": 0.13404880886
    }
  ]
}

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.92308% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.56%. Comparing base (917d689) to head (96d3785).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...manager/src/install/modules_state/settings_diff.rs 95.18% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #17264    +/-   ##
========================================
  Coverage   92.55%   92.56%            
========================================
  Files        1872     1874     +2     
  Lines      242307   242435   +128     
========================================
+ Hits       224278   224417   +139     
+ Misses      18029    18018    -11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@garnet-runtime-review

garnet-runtime-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Execution Profiles recorded for 1 job, triggered by 96d3785

1 job unchanged · compared with c33c58e
recorded at the kernel by Garnet · 2026-10-24 00:07 UTC

TS CI / test ↗ · 24 destinations
@@ c33c58e (previous) vs 96d3785 (current) @@
  systemd
  ├─ bash
  │  └─ bash
  │     └─ bash
  │        └─ bash
  │           └─ bash
  │              └─ bash
  │                 ├─ bash
  │                 │  ├─ bash
  │                 │  │  └─ pn (step: "Validate test chunk inputs")
  │                 │  │     ├─ dash
  │                 │  │     │  └─ node
  │                 │  │     │     └─ pn
  │                 │  │     │        └─ node
  │                 │  │     │           ├─ git
  │                 │  │     │           │  └─ ○ 192.168.127.1
  │                 │  │     │           ├─ node
  │                 │  │     │           │  └─ ○ unofficial-builds.nodejs[.]org
  │                 │  │     │           ├─ ○ codeload.github[.]com
  │                 │  │     │           ├─ ○ github[.]com
  │                 │  │     │           └─ ○ registry.npmjs[.]org
  │                 │  │     └─ ○ nodejs[.]org
  │                 │  └─ gh (step: "Wait for prebuilt pnpr binaries")
  │                 │     └─ ○ api.github[.]com
  │                 └─ node (runner background · +1 −2)
- │                    ├─ pnpm
- │                    │  └─ ○ static.rust-lang[.]org
- │                    ├─ ○ productionresultssa10.blob.core[.]windows
+ │                    └─ ○ productionresultssa6.blob.core.windows[.]net
  ├─ nginx (runner background · −2)
  │  └─ nginx
- │     ├─ ○ 140.82.112.22
- │     ├─ ○ 140.82.114.21
  │     ├─ ○ 8.8.8.8
  │     └─ ○ glb-db52c2cf8be544.github[.]com
  ├─ chronyd (runner background · +4 −4)
+ │  ├─ ○ 144.202.62.209
  │  ├─ ○ 169.254.169.123
+ │  ├─ ○ 172.233.157.223
  │  ├─ ○ 185.125.190.56
  │  ├─ ○ 185.125.190.57
  │  ├─ ○ 185.125.190.58
- │  ├─ ○ 198.12.95.197
- │  ├─ ○ 23.155.72.147
+ │  ├─ ○ 23.172.120.59
- │  ├─ ○ 38.28.93.135
- │  ├─ ○ 66.118.229.14
+ │  ├─ ○ 72.14.186.59
  │  └─ ○ 91.189.91.157
  └─ snapd
     └─ ○ api.snapcraft[.]io
 
  Runner.Worker
  ├─ MainThread
  │  └─ ○ blacksmith.blob.core.windows[.]net
  └─ bash
     ├─ rustup (step: "Initialize Rust before dependenc…tion ($/.github/actions/rustup)")
     │  ├─ ○ dualstack.k.sni.global.fastly[.]net
     │  └─ ○ localhost (dns resolver)
     └─ MainThread
        └─ pn
           └─ dash
              └─ node
                 └─ node
                    └─ node (step: "Validate test chunk inputs")
                       └─ ○ npm.jsr[.]io

View this job's Execution Profile in Garnet →


💡 How to read this
Runner.Worker          ← process on a path
└─ npm
   └─ node             ← process that acted
      └─ ○ npmjs[.]org ← observed action

follow a path downward to see what ran and what it did — each path to an observed action is an execution chain

names on the path = processes · ○ = observed action · (…) = context

+ only in the current record · − only in the previous record · runner background = the runner's infrastructure, not your workflow

@blacksmith-sh

This comment has been minimized.

@zkochan
zkochan marked this pull request as ready for review October 23, 2026 22:38
Copilot AI balanced review requested due to automatic review settings October 23, 2026 22:38

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Reject incompatible modules directories on add, remove, and update

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Make v12 mutations reject incompatible modules directories instead of silently reinstalling them.
• Track store locations in both workspace-state implementations so plain installs detect changes and
 rebuild.
• Keep script verification independent of store location and add recovery tests for both CLIs.
Diagram

graph TD
  CLI["Install command"] --> State{"State drift?"} -->|Yes| Layout{"Modules mismatch?"} -->|Yes| Plain{"Plain install?"} -->|Yes| Rebuild["Recreate modules"] --> Record["Record locations"]
  Plain -->|No| Error["Compatibility error"]
  State -->|No| Reuse["Reuse modules"]
  Layout -->|No| Reuse
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Read .modules.yaml during every repeat-install check
  • ➕ Uses the existing modules manifest as the source of store-location truth.
  • ➖ Adds filesystem work to the optimistic fast path and couples freshness checks to layout metadata.

Recommendation: Keep the PR’s workspace-state approach: it detects configured location changes before the fast path skips installation, without adding a modules-manifest read. Retain the separate layout check to produce the specific compatibility errors.

Files changed (36) +674 / -69

Bug fix (21) +267 / -61
apply_materialization.rsUse the expanded carried-settings field +1/-1

Use the expanded carried-settings field

• Updates applied-state writing to the renamed field that can preserve dependency groups and store locations.

pnpm/crates/package-manager/src/install/apply_materialization.rs

errors.rsAdd actionable modules compatibility errors +33/-3

Add actionable modules compatibility errors

• Defines errors for incompatible layout versions and unexpected store or virtual-store locations, with recovery guidance.

pnpm/crates/package-manager/src/install/errors.rs

modules_state.rsExtract compatibility checks and normalize layout paths +5/-33

Extract compatibility checks and normalize layout paths

• Moves settings-drift validation into a dedicated module. Layout consistency now uses lexical path comparison for recorded store locations.

pnpm/crates/package-manager/src/install/modules_state.rs

settings_diff.rsValidate persisted modules layout before mutations +95/-0

Validate persisted modules layout before mutations

• Checks layout version, store, virtual store, maximum path length, and applicable hoist patterns in upstream order. Accepts the neighboring v3 store and compares paths lexically, ignoring case on Windows.

pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs

purge.rsRestrict incompatible-directory purges to plain installs +7/-7

Restrict incompatible-directory purges to plain installs

• Non-plain mutations now return compatibility errors or keep the directory rather than entering the purge path.

pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs

up_to_date.rsUpdate up-to-date state writing +1/-1

Update up-to-date state writing

• Uses the expanded carried-settings field when refreshing workspace state.

pnpm/crates/package-manager/src/install/prepare_modules_state/up_to_date.rs

write.rsPreserve ignored store settings during state writes +6/-4

Preserve ignored store settings during state writes

• Extends carried settings so verification-triggered state writes retain recorded store and virtual-store locations alongside dependency groups.

pnpm/crates/package-manager/src/install/workspace_state/write.rs

deps_status.rsIgnore store changes during script verification +3/-1

Ignore store changes during script verification

• Excludes both store-location settings from v12 run and exec dependency checks.

pnpm/crates/package-manager/src/optimistic_repeat_install/deps_status.rs

freshness.rsCarry recorded settings through freshness updates +1/-1

Carry recorded settings through freshness updates

• Passes the recorded workspace settings when a freshness policy keeps settings that verification intentionally ignored.

pnpm/crates/package-manager/src/optimistic_repeat_install/freshness.rs

settings.rsInclude store locations in v12 freshness decisions +3/-1

Include store locations in v12 freshness decisions

• Adds resolved configured store locations to current workspace settings and checks them for drift.

pnpm/crates/package-manager/src/optimistic_repeat_install/settings.rs

store_location.rsResolve and compare configured v12 store locations +45/-0

Resolve and compare configured v12 store locations

• Records configured paths in normalized form, leaving unset settings absent. Anchors configured virtual-store paths to the modules directory even when a global virtual store is active.

pnpm/crates/package-manager/src/optimistic_repeat_install/settings/store_location.rs

install.rsTreat update as a non-plain install +1/-1

Treat update as a non-plain install

• Makes update subject to mutation-time modules compatibility checks rather than plain-install purge behavior.

pnpm/crates/package-manager/src/update/install.rs

lib.rsPersist optional store locations in v12 state +9/-0

Persist optional store locations in v12 state

• Adds optional store and virtual-store fields to workspace-state settings for repeat-install drift detection.

pnpm/crates/workspace-state/src/lib.rs

checkDepsStatus.tsCompare resolved store locations in v11 status checks +8/-3

Compare resolved store locations in v11 status checks

• Resolves configured locations against the workspace-state directory before comparing settings, so equivalent path spellings match and actual changes invalidate freshness.

pnpm11/deps/status/src/checkDepsStatus.ts

runDepsStatusCheck.tsAllow v11 scripts across store changes +3/-2

Allow v11 scripts across store changes

• Ignores store and virtual-store settings during run and exec dependency verification.

pnpm11/exec/commands/src/runDepsStatusCheck.ts

installDeps.tsKeep the configured store option intact +3/-1

Keep the configured store option intact

• Passes a copy of install options to the store controller so its resolved-store mutation does not overwrite the setting recorded in workspace state.

pnpm11/installing/commands/src/installDeps.ts

workspaceStateUpdate.tsPreserve configured store for recursive state writes +7/-1

Preserve configured store for recursive state writes

• Captures storeDir before recursive installation and uses it when updating workspace state.

pnpm11/installing/commands/src/workspaceStateUpdate.ts

index.tsExport store-location resolution +1/-0

Export store-location resolution

• Exposes the shared resolver to workspace-state writers and dependency-status checks.

pnpm11/workspace/state/src/index.ts

storeLocation.tsNormalize configured v11 store locations +25/-0

Normalize configured v11 store locations

• Resolves relative store and virtual-store paths against the state directory, appends the store version when needed, and preserves unset settings.

pnpm11/workspace/state/src/storeLocation.ts

types.tsTrack store locations among v11 state settings +5/-0

Track store locations among v11 state settings

• Adds storeDir and virtualStoreDir to the settings checked for workspace-state freshness.

pnpm11/workspace/state/src/types.ts

updateWorkspaceState.tsRecord resolved locations in v11 workspace state +5/-1

Record resolved locations in v11 workspace state

• Normalizes configured store paths before creating and writing workspace state.

pnpm11/workspace/state/src/updateWorkspaceState.ts

Tests (7) +377 / -4
main.rsRegister modules compatibility tests +1/-0

Register modules compatibility tests

• Includes the new CLI integration test module in the suite.

pnpm/crates/cli/tests/suite/main.rs

modules_dir_compatibility.rsExercise refusal, recovery, and verification in v12 +260/-0

Exercise refusal, recovery, and verification in v12

• Tests store, virtual-store, and layout incompatibilities without mutation-time purges. Also covers plain-install recovery, script verification, node-linker drift, and global virtual-store state.

pnpm/crates/cli/tests/suite/modules_dir_compatibility.rs

repeat_install.rsAdapt repeat-install tests to carried settings +3/-3

Adapt repeat-install tests to carried settings

• Renames carried-settings fields in existing fast-path and partial-install test fixtures.

pnpm/crates/package-manager/src/install/tests/repeat_install.rs

tests.rsAdapt workspace-state test fixture +1/-1

Adapt workspace-state test fixture

• Updates the existing state-recording fixture to the expanded carried-settings field.

pnpm/crates/package-manager/src/optimistic_repeat_install/tests.rs

storeLocationChange.tsTest v11 store-location recovery +71/-0

Test v11 store-location recovery

• Verifies that add rejects changed locations while install recreates modules, and that single-project and recursive installs record the configured store.

pnpm11/installing/commands/test/storeLocationChange.ts

singleProjectWorkspace.tsTest script verification before store migration +21/-0

Test script verification before store migration

• Confirms a script runs after a store change without replacing the recorded setting, and a subsequent install relinks modules from the new store.

pnpm11/pnpm/test/verifyDepsBeforeRun/singleProjectWorkspace.ts

storeLocation.test.tsTest v11 path normalization +20/-0

Test v11 path normalization

• Checks that equivalent relative and absolute store paths resolve identically and unspecified locations remain unset.

pnpm11/workspace/state/test/storeLocation.test.ts

Documentation (5) +23 / -4
refuse-modules-dir-from-another-store.mdDocument v12 compatibility and reinstall behavior +9/-0

Document v12 compatibility and reinstall behavior

• Adds a pacquet patch release note for mutation errors, plain-install recovery, and update’s layout-setting checks.

.changeset/refuse-modules-dir-from-another-store.md

reinstall-after-store-location-change.mdDocument v11 store-location recovery +9/-0

Document v11 store-location recovery

• Adds patch release notes for the v11 packages affected by workspace-state tracking and reinstall behavior.

.changeset/reinstall-after-store-location-change.md

layout.rsCorrect the documented virtual-store error code +1/-1

Correct the documented virtual-store error code

• Aligns the layout documentation with the compatibility error now reported.

pnpm/crates/config/src/layout.rs

store_path.rsClarify cross-CLI store switching behavior +3/-2

Clarify cross-CLI store switching behavior

• Documents that mutations reject a modules directory linked from the other store until a plain install recreates it.

pnpm/crates/config/src/store_path.rs

store.rsCorrect store-test error documentation +1/-1

Correct store-test error documentation

• Updates a global virtual-store test comment to name the reported compatibility error.

pnpm/crates/package-manager/src/install/tests/store.rs

Other (3) +7 / -0
package.jsonDeclare the store-version constants dependency +1/-0

Declare the store-version constants dependency

• Adds @pnpm/constants for resolving configured store paths in workspace state.

pnpm11/workspace/state/package.json

tsconfig.jsonReference the constants TypeScript project +3/-0

Reference the constants TypeScript project

• Adds the project reference required by the new store-version import.

pnpm11/workspace/state/tsconfig.json

pnpm-lock.yamlLock the new workspace dependency +3/-0

Lock the new workspace dependency

• Records @pnpm/constants as a dependency of the v11 workspace-state package.

pnpm-lock.yaml

@qodo-code-review

qodo-code-review Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Filtered adds break unselected projects ✓ Resolved
Description
purge_inconsistent_modules_dir now purges the workspace modules directory after a non-plain
mutation passes the settings check, including when only nodeLinker changed. With `pnpm --filter
selected add` after a hoisted-to-isolated switch, the purge removes root-level hoisted links used by
unselected projects, while filtered materialization relinks only the selected importer closure.
Code

↗ pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[R24-27] Commit e891c23c4332ae7c35c206296806fa6f43b39611

+    if !context.installs_only
+        && let Some(modules) = context.modules_manifest
+    {
+        check_modules_settings_diff(modules, context.config)?;
Relevance

●●● Strong

Recent filtered-hoisted fixes preserve unselected projects, closely matching this regression.

PR-#16486
PR-#15480

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Linker drift makes the layout inconsistent but is not rejected by the non-plain settings check. The
changed branch therefore reaches a purge that removes ordinary root entries; project selection then
limits relinking to the requested importer closure. The new compatibility test independently
confirms that a hoisted root link is removed by this linker-switch purge.

pnpm/crates/package-manager/src/install/modules_state.rs[204-217]
pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[4-9]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[24-47]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[64-96]
pnpm/crates/package-manager/src/install/apply_materialization/selection.rs[27-63]
pnpm/crates/package-manager/src/install/apply_materialization.rs[87-107]
pnpm/crates/cli/tests/suite/modules_dir_compatibility.rs[120-134]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A filtered mutation can purge workspace-wide links after linker drift but rebuild only selected projects, leaving unselected projects without dependencies.
## Fix Focus Areas
- pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[20-47]
- pnpm/crates/package-manager/src/install/apply_materialization/selection.rs[27-63]
## Recommended Fix
When a filtered mutation requires a workspace-wide purge, ensure materialization restores every affected importer and root-level link, or reject the mutation before purging and require an unfiltered install. Add a workspace regression test with an unselected project that depends on a hoisted package.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. A null layout erases user files on add ✓ Resolved
Description
purge_inconsistent_modules_dir skips compatibility validation when .modules.yaml reads as
null, then continues into the purge for non-plain mutations. When that file exists alongside
ordinary user files or directories in node_modules, pnpm add now deletes those entries despite
having no readable record that pnpm owns the layout.
Code

↗ pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[R24-27] Commit e891c23c4332ae7c35c206296806fa6f43b39611

+    if !context.installs_only
+        && let Some(modules) = context.modules_manifest
+    {
+        check_modules_settings_diff(modules, context.config)?;
Relevance

●●● Strong

A close precedent stopped purging node_modules for unreadable or malformed modules metadata.

PR-#14073

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The modules-layout reader accepts a null document as None, while layout preparation treats an
existing .modules.yaml with no parsed layout as inconsistent. The new conditional bypasses
validation for that value and reaches a purge that removes every non-hidden entry, including entries
not identified through a modules manifest.

pnpm/crates/modules-yaml/src/lib.rs[469-477]
pnpm/crates/package-manager/src/install/prepare_modules_state.rs[313-328]
pnpm/crates/package-manager/src/install/prepare_modules_state.rs[125-140]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[24-47]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[64-96]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A present `.modules.yaml` containing `null` triggers a non-plain mutation purge without a readable layout record, deleting ordinary entries in `node_modules`.
## Fix Focus Areas
- pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[20-47]
- pnpm/crates/package-manager/src/install/prepare_modules_state.rs[313-328]
## Recommended Fix
For non-plain mutations, do not purge when the manifest is absent or unreadable but the metadata file exists. Return an actionable error requiring a plain install, and test that an add preserves ordinary files in this case.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Store changes can leave links on the old store ✗ Dismissed
Description
resolveStoreDir resolves a relative storeDir against the workspace-state directory, but
createStoreController resolves it against workspaceDir or dir. When lockfileDir differs from
that directory, the state records a path the installer did not use; changing the setting to that
recorded absolute path then appears unchanged to dependency-status checks, so an optimistic install
can leave the existing links in place.
Code

pnpm11/workspace/state/src/storeLocation.ts[R23-24]

+  const resolved = path.resolve(stateDir, storeDir)
+  return path.basename(resolved) === STORE_VERSION ? resolved : path.join(resolved, STORE_VERSION)
Relevance

●●● Strong

Workspace-state path consistency bugs are treated as actionable correctness issues, especially when
resolver bases differ.

PR-#17034
PR-#16237

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The store controller and new state resolver use different bases, while the status check compares
only the newly resolved state values.

pnpm11/store/connection-manager/src/index.ts[43-55]
pnpm11/installing/commands/src/workspaceStateUpdate.ts[61-73]
pnpm11/workspace/state/src/updateWorkspaceState.ts[56-61]
pnpm11/workspace/state/src/storeLocation.ts[15-25]
pnpm11/deps/status/src/checkDepsStatus.ts[151-167]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
With separate workspace and lockfile directories, workspace state records a different effective store from the one used by the installer. This can hide a real store change from the repeat-install check.

## Fix Focus Areas
- pnpm11/workspace/state/src/storeLocation.ts[15-25]
- pnpm11/installing/commands/src/workspaceStateUpdate.ts[61-73]
- pnpm11/deps/status/src/checkDepsStatus.ts[151-167]

## Recommended Fix
Resolve relative store paths against the same workspace/project base passed to `createStoreController`, independently of the directory containing workspace state. Pass that base consistently to state writing and status checks, and test a separate `lockfileDir` with a store change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (2)
4. Stable installs break in a patch release ✗ Dismissed
Description
The pacquet changeset declares a patch release for changing add, remove, and update from
silently reinstalling dependencies to failing with compatibility errors. Existing v12 users who
relied on the previous stable behavior now receive failures and must run a separate install, so this
incompatible command contract requires a major version bump.
Code

.changeset/refuse-modules-dir-from-another-store.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

●●● Strong

Recent accepted precedents require release metadata changes when behavior breaks compatibility, even
for patch-intended fixes.

PR-#17270
PR-#17112

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The implementation changes non-install mutations to return compatibility errors instead of purging,
while the affected pacquet changeset assigns only a patch bump. This is the stable behavior change
covered by the major-version requirement.

.changeset/refuse-modules-dir-from-another-store.md[1-5]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[20-26]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset publishes a breaking change to established install commands as a patch release, although incompatible modules directories previously triggered silent recreation and now produce errors.

## Fix Focus Areas
- .changeset/refuse-modules-dir-from-another-store.md[1-5]

## Recommended Fix
Change the affected stable CLI package from a patch bump to a major bump, or otherwise document and apply the repository's approved compatibility policy for this behavior change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Store moves stop automated updates ✗ Dismissed
Description
update_execution now makes pnpm update refuse an existing modules directory linked from a
different store, but pnpm/update self-updates pnpm before running that command. When
refresh-lockfile is false and the new pnpm version selects a different store, the action retains
the old node_modules and its update fails instead of producing a pull request.
Code

pnpm/crates/package-manager/src/update/install.rs[196]

+        installs_only: false,
Relevance

●● Moderate

This is a cross-repository workflow interaction with no closely matching historical acceptance or
rejection precedent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR routes updates through non-plain-install validation, which rejects a recorded store mismatch.
The action permits retaining the existing installation, self-updates pnpm first, and then invokes
update.

pnpm -> update
pnpm/crates/package-manager/src/update/install.rs[193-199]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[20-27]
pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[50-60]
External repo: pnpm/update, action.yml [36-49]
External repo: pnpm/update, scripts/update.sh [20-35]
External repo: pnpm/update, scripts/update.sh [55-87]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
pnpm/update can retain an installation made with the old store when it self-updates pnpm, causing the newly strict `pnpm update` to fail.

## Fix Focus Areas
- pnpm/crates/package-manager/src/update/install.rs[193-199]
- /cross_repos/update/scripts/update.sh[20-35]
- /cross_repos/update/scripts/update.sh[55-87]

## Recommended Fix
Coordinate with pnpm/update: when self-update changes the selected store and refresh-lockfile is false, run a plain `pnpm install` to reconcile the existing modules directory before `pnpm update`. Preserve the refusal for direct user-initiated mutations.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

6. Release notes mix linker and store fixes ✓ Resolved
Description
The changeset's first paragraph combines store, virtual-store, layout-version, and node-linker
failure behavior in one compound sentence. Readers must parse several independent command outcomes
and error codes together, making the release note harder to understand and verify against the actual
change.
Code

.changeset/refuse-modules-dir-from-another-store.md[5]

+`pnpm add`, `pnpm remove`, and `pnpm update` now fail if `node_modules` was linked from a different store, a different virtual store directory, or by an incompatible pnpm version. They report `ERR_PNPM_UNEXPECTED_STORE`, `ERR_PNPM_UNEXPECTED_VIRTUAL_STORE`, or `ERR_PNPM_MODULES_BREAKING_CHANGE`. They also fail with `ERR_PNPM_NODE_LINKER_DIFF` if `node_modules` was installed with a different `nodeLinker`. Previously, these commands removed and reinstalled `node_modules` without asking. Run `pnpm install` to recreate it.
Relevance

●●● Strong

Recent changeset reviews consistently accept splitting compound release-note behavior into clearer
sentences.

PR-#17267
PR-#17164
PR-#17140

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The modified paragraph adds a separate node-linker failure mode to an already compound sentence that
also covers several other independent failure modes and commands.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/refuse-modules-dir-from-another-store.md[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The first changeset paragraph combines multiple independent observable behavior changes and their error codes in one compound sentence.

## Fix Focus Areas
- .changeset/refuse-modules-dir-from-another-store.md[5-5]

## Recommended Fix
Split the store, virtual-store, layout-version, and node-linker behavior into separate direct sentences or separate release-note bullets, with each sentence describing one logical user-visible change.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Adds reject older isolated installs ✓ Resolved
Description
refuse_drifted_modules_dir treats an absent nodeLinker field as different from the configured
isolated linker. A layout-version-5 manifest from an older pnpm install can pass the preceding
settings checks with matching paths and patterns, yet pnpm add, remove, and update now stop
with ERR_PNPM_NODE_LINKER_DIFF even when the linker has not changed.
Code

pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[R23-24]

+    if modules.node_linker != Some(map_node_linker(node_linker)) {
+        return Err(InstallError::NodeLinkerDiff);
Relevance

●●● Strong

Legacy manifest compatibility is a concrete correctness regression; related install-state
compatibility fixes were accepted.

PR-#14073
PR-#13536

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The repository contains a pnpm 5.1.8 layout-version-5 manifest without nodeLinker. Reading leaves
that field unset while normalizing its omitted length and relative virtual-store path; the new
comparison then rejects it after the other settings match.

pnpm/crates/modules-yaml/tests/fixtures/old-no-shamefully-hoist/.modules.yaml[1-22]
pnpm/crates/modules-yaml/src/lib.rs[197-207]
pnpm/crates/modules-yaml/src/lib.rs[493-508]
pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[70-91]
pnpm/crates/config/src/setting_types.rs[101-108]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Older compatible layout-version-5 manifests can omit `nodeLinker`; comparing that missing value directly with the configured linker falsely reports a linker change.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[22-25]
- pnpm/crates/package-manager/src/install/modules_state/settings_diff/tests.rs[17-22]

## Recommended Fix
Distinguish a recorded, different linker from an absent legacy field. Preserve the refusal for explicit mismatches, and add a test for a compatible legacy manifest without `nodeLinker`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Home-relative stores trigger extra installs 🐞 Bug ➹ Performance
Description
resolveStoreDir passes a ~/ store setting to path.resolve, treating the tilde as a directory
name inside the workspace rather than the home-path syntax recognized by getStorePath. When a user
changes from ~/store to an absolute spelling of the same effective store, the recorded settings
differ and the repeat-install check needlessly takes the install path.
Code

pnpm11/workspace/state/src/storeLocation.ts[R23-24]

+  const resolved = path.resolve(stateDir, storeDir)
+  return path.basename(resolved) === STORE_VERSION ? resolved : path.join(resolved, STORE_VERSION)
Relevance

●●● Strong

The tilde handling is a deterministic path-resolution bug affecting repeat-install state
comparisons.

PR-#17034
PR-#16237

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The actual store-path implementation branches on ~/ and ~\, whereas the new workspace-state
resolver unconditionally uses path.resolve; the state comparison includes this value.

pnpm11/store/path/src/index.ts[25-44]
pnpm11/store/path/src/index.ts[125-133]
pnpm11/workspace/state/src/storeLocation.ts[15-25]
pnpm11/deps/status/src/checkDepsStatus.ts[151-160]
pnpm11/config/commands/test/configGet.test.ts[8-20]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Workspace-state normalization interprets supported `~/` store paths as workspace-relative, producing a value unrelated to the effective store and invalidating repeat installs when the setting is respelled.

## Fix Focus Areas
- pnpm11/workspace/state/src/storeLocation.ts[15-25]

## Recommended Fix
Make normalization account for the same home-path handling and store placement semantics used by `getStorePath`; test equivalent home-relative and absolute settings without adding filesystem probes to every status check.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (2)
9. Release notes mix old and new behavior ✓ Resolved
Description
Both new changesets place past-tense claims such as used to remove and reinstall and `It used to
report "Already up to date"` in the same sentences as the corrected behavior. Readers cannot
distinguish the current release behavior from the prior defect, and the release notes do not follow
the required separate past-tense sentence format.
Code

.changeset/refuse-modules-dir-from-another-store.md[5]

+`pnpm add`, `pnpm remove`, and `pnpm update` now fail if `node_modules` was linked from a different store, a different virtual store directory, or by an incompatible pnpm version. They report `ERR_PNPM_UNEXPECTED_STORE`, `ERR_PNPM_UNEXPECTED_VIRTUAL_STORE`, or `ERR_PNPM_MODULES_BREAKING_CHANGE`. These commands used to remove and reinstall `node_modules` without asking. Only `pnpm install` recreates `node_modules` now.
Evidence
The changeset text describes new behavior and prior behavior in the same sentences, including `These
commands used to remove and reinstall node_modules without asking, It used to report "Already up
to date"`, and the same pattern in the second changeset. PR Compliance ID 3058498 requires previous
buggy behavior to be described in a separate past-tense sentence.

Rule 3058498: Describe previous buggy behavior in a separate past-tense sentence
.changeset/refuse-modules-dir-from-another-store.md[5-7]
.changeset/reinstall-after-store-location-change.md[9-9]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset combines the corrected behavior with descriptions of what happened previously, using phrases such as `used to` in the same sentence or paragraph. Release notes must describe the previous buggy behavior in its own past-tense sentence rather than as a trailing comparison.

## Fix Focus Areas
- .changeset/refuse-modules-dir-from-another-store.md[5-7]
- .changeset/reinstall-after-store-location-change.md[9-9]

## Recommended Fix
Rewrite each affected entry so the current behavior is stated in one sentence and the prior behavior is stated in a separate past-tense sentence beginning with `Previously` or equivalent wording. Preserve the user-visible command and error details while removing trailing `instead of`, `rather than`, or `used to` comparisons from the new-behavior sentences.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Linker switch on add leaves a mixed tree ✓ Resolved
Description
purge_inconsistent_modules_dir now returns right after check_modules_settings_diff whenever
installs_only is false. That check deliberately skips nodeLinker, but
modules_layout_consistent_with still counts a linker change as drift (and the same early return
covers a .modules.yaml that parses as null). Downstream code still assumes the purge happened:
materialized_current_lockfile drops the previous current lockfile when is_inconsistent, and
commit writes a fresh .modules.yaml with the new linker. So after pnpm add/remove/update the
old linker's entries stay in node_modules, and the next plain pnpm install sees a consistent
layout and never cleans them up.
Code

pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[R23-26]

+    if !context.installs_only {
+        return context.modules_manifest.map_or(Ok(()), |modules| {
+            check_modules_settings_diff(modules, context.config)
+        });
Relevance

●● Moderate

The concern is technically specific, but the PR explicitly intends to preserve modules after
nodeLinker changes and adds a regression test.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
modules_layout_consistent_with includes `modules.node_linker ==
Some(map_node_linker(node_linker)), so a linker change sets is_inconsistent`.
check_modules_settings_diff has no linker check (its doc says upstream checks no nodeLinker
drift), so the new early return succeeds and nothing is purged. selection.rs then uses the
previous current lockfile only when !inputs.is_inconsistent, and commit writes a new manifest with
the current linker. Before this PR the code fell through to the purge, so this downstream handling
was safe.

pnpm/crates/package-manager/src/install/modules_state.rs[192-218]
pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[6-25]
pnpm/crates/package-manager/src/install/apply_materialization/selection.rs[75-92]
pnpm/crates/package-manager/src/install/prepare_modules_state.rs[122-136]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
For non-plain installs (`pnpm add`/`remove`/`update`), `purge_inconsistent_modules_dir` no longer purges a modules directory that `modules_layout_consistent_with` reports as drifted but `check_modules_settings_diff` accepts. The main case is a `nodeLinker` change; another is a `.modules.yaml` that parses as `null`. Downstream materialization still treats the tree as inconsistent. It drops the previous current lockfile and writes a fresh `.modules.yaml` recording the new layout, so the old linker's entries stay behind and a later `pnpm install` no longer detects the drift.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[20-27]
- pnpm/crates/package-manager/src/install/apply_materialization/selection.rs[75-92]
- pnpm/crates/package-manager/src/install/modules_state.rs[192-218]

## Recommended Fix
Pick one of these:
1. When `installs_only` is false and the drift is not one `check_modules_settings_diff` rejects (for example `nodeLinker`), return an error telling the user to run `pnpm install`.
2. Or, when the purge is skipped, pass `is_inconsistent = false` downstream, keep the previous current lockfile, and keep the recorded linker, so the next plain install still detects and purges the drift.
Add a test: install with `nodeLinker: hoisted`, switch to `isolated`, run `pnpm add`, then `pnpm install`, and assert that no hoisted leftovers remain.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

11. Windows path drift goes untested ✓ Resolved
Description
same_path normalizes store and virtual-store paths but uses eq_ignore_ascii_case on Windows,
leaving non-ASCII casing differences unmatched; the added compatibility tests do not cover Windows
separators or casing. When a recorded path is respelled with different non-ASCII casing on a
case-insensitive Windows volume, store or virtual-store compatibility checks can reject the same
directory and affect install decisions without the current tests catching it.
Code

pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[R87-94]

+pub(in super::super) fn same_path(left: &Path, right: &Path) -> bool {
+    let left = pnpm_fs::lexical_normalize(left);
+    let right = pnpm_fs::lexical_normalize(right);
+    if cfg!(windows) {
+        left.as_os_str().eq_ignore_ascii_case(right.as_os_str())
+    } else {
+        left == right
+    }
Relevance

● Weak

Recent Windows-specific test-coverage requests for path handling were rejected as unnecessary.

PR-#17138
PR-#15347

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed implementation uses a Windows-specific case-insensitive comparison after normalizing
paths, but eq_ignore_ascii_case folds only ASCII characters. Both store and virtual-store
compatibility checks use this comparison, and their mismatches become user-facing errors; the added
test helper normalizes paths without exercising Windows separators, casing, or a Windows-specific
execution case.

pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[85-94]
pnpm/crates/cli/tests/suite/modules_dir_compatibility.rs[240-245]
pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[54-69]
pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[85-95]
pnpm/crates/package-manager/src/install/prepare_modules_state/purge.rs[20-26]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Windows compatibility check compares normalized paths using ASCII-only case folding, so equivalent paths with non-ASCII casing differences can be rejected. Current regression coverage does not exercise Windows separators or casing.

## Fix Focus Areas
- pnpm/crates/package-manager/src/install/modules_state/settings_diff.rs[85-95]
- pnpm/crates/cli/tests/suite/modules_dir_compatibility.rs[240-245]

## Recommended Fix
Retain lexical path normalization and use a Windows-appropriate case-insensitive path comparison. Add a direct unit test or explicit Windows test case covering equivalent paths with Windows separators and different casing, including non-ASCII casing, and assert that incompatible paths remain distinct.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 52 rules
Review mode: Auto: ⏭️ Skipped: Only a changeset documentation clarification changed; no runtime behavior is affected.

Grey Divider

⚠️ Warning | Comment size exceeded, non finding content trimmed Learn more

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 23, 2026
zkochan and others added 5 commits October 24, 2026 00:57
pnpm v12 let `pnpm add`, `pnpm remove`, and `pnpm update` silently purge
and reinstall `node_modules` when `.modules.yaml` recorded a different
store, virtual store directory, or layout version. Its port of
`validateModules` carried only the hoist-pattern and
`virtualStoreDirMaxLength` checks, and `pnpm update` ran as a plain
install, so it skipped even those.

pnpm v11 (`validateModules` and `checkCompatibility` in
pnpm11/installing/deps-installer/src/install/) fails every mutation
other than a plain install with ERR_PNPM_MODULES_BREAKING_CHANGE,
ERR_PNPM_UNEXPECTED_STORE, or ERR_PNPM_UNEXPECTED_VIRTUAL_STORE, and only
`pnpm install` takes the purge path. `installsOnly` is false for an
install with `update` set, so `pnpm update` errors too.

`check_modules_settings_diff` now runs the `checkCompatibility` checks
after the `*_DIFF` ones, in v11's order, and moves to its own module to
keep `modules_state.rs` under the file-length limit. Paths compare
lexically, case-insensitively on Windows, like `path.relative`, and the
neighbouring `v3` store is accepted as v11 does. The hoist-pattern
checks skip a `virtualStoreOnly` manifest, as v11 does. The error text
and help match the v11 error message and the default reporter's body.
`pnpm update` now passes `installs_only: false`.

The confirmModulesPurge prompt stays out: v12 lists it as a pnpm v11
setting and purges without asking.

The new modules_dir_compatibility e2e module covers add, remove, and
update against a changed `storeDir`, add against a changed
`virtualStoreDir` and layout version, and that `pnpm install` then
recreates the tree. All three tests fail with the check disabled, and
the update case fails with `installs_only: true` restored.

Part of pnpm/tasks#191.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ERR_PNPM_UNEXPECTED_STORE and ERR_PNPM_UNEXPECTED_VIRTUAL_STORE tell the
user to run `pnpm install`, but in both CLIs the optimistic repeat
install reported "Already up to date": the workspace state recorded
neither setting, so nothing invalidated the fast path.

Both stacks now record the configured `storeDir` and `virtualStoreDir`
in the workspace state and compare them like the other settings, so the
next `pnpm install` takes the full install, which purges and recreates
`node_modules`. The fast path reads no extra file.

The recorded values are the raw configured ones, the same in both
stacks, so either CLI accepts the state the other wrote:

- v11 records `opts.storeDir` as configured (`~/` expanded). Its store
  controller writes the resolved store into the options it is given, so
  `installDeps` now passes it a copy, and the recursive install, whose
  context does the same, snapshots the value before it runs.
- v12 reads both from `explicit_settings` and expands a leading `~/` in
  `storeDir` as v11 does. A deploy records the store location its
  deployed `pnpm-workspace.yaml` carries (no `storeDir`, and only a
  relative `virtualStoreDir`), so `pnpm run` in the deploy directory
  still passes dependency verification.

The layout version is not recorded: it has been 5 since before the
workspace state existed, so only a hand-edited `.modules.yaml` can
disagree with it.

ERR_PNPM_MODULES_BREAKING_CHANGE now uses the default reporter's title
and help, as the other two errors do.

Tests: the v12 e2e module drops its optimistic-repeat-install
workaround, checks the reinstall after both changes, and checks that
the state records `storeDir` as configured. A new v11 test
(installing/commands/test/storeLocationChange.ts) checks that an
unchanged repeat install stays on the fast path, that `pnpm add` fails
and `pnpm install` reinstalls after each change, and that single-project
and recursive installs record the configured `storeDir`. Each fails with
the new setting keys removed, and the v11 recording tests fail without
the copy and the snapshot.

Part of pnpm/tasks#191.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first version recorded `storeDir` and `virtualStoreDir` as
spelled. TS CI showed two ways that breaks: a verification-triggered
install passes the store as an absolute path while the user spells it
relative, and a shared-lockfile deploy installs with an absolute
`virtualStoreDir` that the deployed directory's own config does not
name. Rust CI on Windows failed on separator-sensitive assertions in
the new e2e test.

Both stacks now record each configured setting as the directory it
resolves to, against the directory of the workspace state, with the
store version appended to `storeDir` as the store resolution does. A
setting that is not configured stays unset, so a project that sets
neither records nothing.

`pnpm run` and `pnpm exec` dependency verification ignore both
settings and carry the recorded ones forward, as they do for the
dependency groups: a script runs the same from whichever store
`node_modules` was linked from, and only an install has to act on the
change. This also keeps a deployed project passing verification without
deploy-specific handling, so the v12 deploy change is reverted.

The e2e test now compares recorded paths by component, so it holds on
Windows. A unit test covers the v11 path resolution.

Part of pnpm/tasks#191.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tual store

Review follow-ups.

`pnpm add`, `pnpm remove`, and `pnpm update` could still purge
`node_modules`: `purge_inconsistent_modules_dir` ran the `validateModules`
checks and then purged anyway for any drift they do not report, such as
a `nodeLinker` change. pnpm v11 never purges for a mutation other than a
plain install (`forceNewModules = installsOnly`), so a non-install
mutation now either fails on the reported drift or keeps the directory.
The layout-drift check also compares the recorded store and virtual
store with `same_path`, the comparison the errors use, rather than as
exact strings, so a spelling difference (case on Windows, `..`
segments) no longer reads as drift.

Under a global virtual store, v12 recorded the global virtual store as
`virtualStoreDir` in the workspace state. It now records the configured
`virtualStoreDir` anchored at the lockfile directory, as v11 does.

Tests: an e2e case where `add` after a `nodeLinker` change keeps a file
in `node_modules` (fails against the previous commit), a case where
`pnpm run` passes verification after a `storeDir` change and keeps the
recorded store until `pnpm install` recreates the tree (in both stacks;
the v12 one fails without the ignore list), and a case for the recorded
`virtualStoreDir` under a global virtual store (fails with the previous
recording).

The v11 changeset now names `@pnpm/deps.status` and
`@pnpm/exec.commands`, which the change also touches.

Part of pnpm/tasks#191.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… base

v11's store controller resolves a relative `storeDir` against the
workspace directory, else the project. The workspace state resolved it
against its own directory, the lockfile directory. With a project lockfile
inside a workspace, the state recorded a store the installer never used,
so switching to that path's absolute spelling looked unchanged.

`virtualStoreDir` keeps resolving against the lockfile directory, as the
install context does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zkochan
zkochan force-pushed the fix-unexpected-store-error branch from dbf6558 to 5258adb Compare October 23, 2026 23:04
Copilot AI balanced review requested due to automatic review settings October 23, 2026 23:04

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5258adb

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 96d3785

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan

zkochan commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed and review finished.

@zkochan

zkochan commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@zkochan
zkochan merged commit f2b319c into main Oct 24, 2026
75 of 77 checks passed
@zkochan
zkochan deleted the fix-unexpected-store-error branch October 24, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants