Repository navigation
fix(package-manager): don't write the PnP loader for a virtual-store-only install - #13636
Conversation
…only install `virtualStoreOnly` populates the virtual store and creates no importer links — it is how `pnpm fetch` warms a store in a Docker layer without touching the project. The importer symlinks and `node_modules/.package-map.json` were already skipped on that path, but `.pnp.cjs` was not. `.pnp.cjs` is how a PnP project resolves, which makes it a project-level artifact of exactly the same kind: writing it leaves the project claiming to resolve out of a store it was never linked into. Gate it on `virtualStoreOnly` like the other two. Fixed in all four implementations, since every one carried the gap: `deps-installer` and `deps-restorer` on the TypeScript side, and the fresh and frozen paths in pacquet. The headless path reuses the `skipPostImportLinking` flag it already derives. Forbidding the combination instead was considered and rejected: `pnpm fetch` sets `virtualStoreOnly`, so erroring would stop PnP users warming a store at all, which is a legitimate thing to want. Two regression tests, each verified to fail when its own guard is removed: - `fetch_under_pnp_does_not_write_the_loader` covers the frozen path (`fetch` pins `frozenLockfile`, so it always goes headless). - `virtual_store_only_install_under_pnp_does_not_write_the_loader` covers the fresh path, reachable because `virtualStoreOnly` is a `pnpm-workspace.yaml` setting a plain install can carry. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PR Summary by QodoSkip writing .pnp.cjs when virtualStoreOnly warms the store
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughPnP loader generation now skips ChangesPnP loader suppression
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant PackageManager
participant LifecycleScripts
CLI->>PackageManager: Run fetch or virtualStoreOnly install
PackageManager->>PackageManager: Check virtual_store_only and linking state
alt Loader generation enabled
PackageManager->>PackageManager: Generate .pnp.cjs
PackageManager->>LifecycleScripts: Inject --require .pnp.cjs
else Loader generation skipped
PackageManager->>LifecycleScripts: Omit PnP loader options
end
LifecycleScripts-->>CLI: Complete operation
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously requested TypeScript coverage now exercises both fresh and headless virtual-store-only PnP paths. Reviews (4): Last reviewed commit: "test(package-manager): use STORE_VERSION..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/cli/tests/install.rs`:
- Around line 1949-1952: Update the install test around the existing .pnp.cjs
assertion to also verify that store_dir.join("v11") exists after install,
ensuring the fresh path materializes the store while still asserting the PnP
loader is absent.
In `@pnpm11/installing/deps-installer/src/install/index.ts`:
- Around line 1884-1888: Prevent dependency builds from receiving a suppressed
PnP loader: in pnpm11/installing/deps-installer/src/install/index.ts, gate the
dependency-build makeNodeRequireOption() call near lines 1918-1922 with
!opts.virtualStoreOnly; in pnpm11/installing/deps-restorer/src/index.ts, gate
the corresponding call near lines 621-625 with !skipPostImportLinking. Keep the
existing PnP artifact suppression behavior unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 98b8cb66-6ed6-4f98-a9fc-fdccd22f6bda
📒 Files selected for processing (7)
.changeset/pnp-loader-virtual-store-only.mdpnpm/crates/cli/tests/fetch.rspnpm/crates/cli/tests/install.rspnpm/crates/package-manager/src/install_frozen_lockfile.rspnpm/crates/package-manager/src/install_with_fresh_lockfile/linking.rspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-restorer/src/index.ts
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13636 +/- ##
=======================================
Coverage 88.05% 88.05%
=======================================
Files 573 573
Lines 98389 98390 +1
=======================================
+ Hits 86636 86639 +3
+ Misses 11753 11751 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Withholding `.pnp.cjs` under `virtualStoreOnly` left both TypeScript paths still passing that path to Node with `--require`, so a dependency lifecycle script would fail before it could run. The package-map option directly below was already gated on whether its file was written; the loader option now follows the same rule. Adds the TypeScript coverage the guards were missing, mirroring the existing package-map tests: - `deps-installer`: asserts the loader is absent *and* that a dependency install script still runs, which is what proves the env is clean. - `deps-restorer`: asserts the virtual store is populated and the loader is not written. Each was verified to fail with its own guard removed. The Rust fresh-path test now also asserts store population, so loader-absence cannot pass by the install stopping early. pacquet needs no equivalent change: it does not wire a PnP `--require` into the build environment. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 88b72ea |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm11/installing/deps-installer/test/install/misc.ts`:
- Around line 206-217: Update the regression assertions so both tests prove
virtual-store population, not merely filesystem setup: in
pnpm11/installing/deps-installer/test/install/misc.ts lines 206-217, assert a
concrete populated package entry or store metadata after
addDependenciesToPackage while retaining the .pnp.cjs absence and marker checks;
in pnpm11/installing/deps-restorer/test/index.ts lines 830-831, replace the
virtual-store directory-existence assertion with an assertion for the known
fixture package or expected store contents, while preserving the required
.pnp.cjs/NODE_OPTIONS checks.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8810f06a-be81-43da-ac90-31a195a9a9ad
📒 Files selected for processing (5)
pnpm/crates/cli/tests/install.rspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/test/install/misc.tspnpm11/installing/deps-restorer/src/index.tspnpm11/installing/deps-restorer/test/index.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- pnpm11/installing/deps-installer/src/install/index.ts
- pnpm11/installing/deps-restorer/src/index.ts
- pnpm/crates/cli/tests/install.rs
…e-only tests Both new TypeScript tests asserted the loader's absence without proving the install had populated anything, so each could have passed on an install that bailed early. The headless test now asserts an extracted file (`rimraf/package.json`) rather than the virtual-store directory, and the fresh test asserts the dependency reached a virtual-store slot. Checking an extracted file rather than a directory listing also survives the intra-store dependency links, which `virtualStoreOnly` still creates — those belong to the store, not the project. Reported by CodeRabbit.
|
Code review by qodo was updated up to the latest commit 8125a01 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…ssertion helper
Two review findings, neither affecting behaviour:
- `fetch.rs` asserted `store_dir.join("v11")`, which silently goes stale
when the store layout version moves. It now uses
`pacquet_store_dir::STORE_VERSION`, which the global-virtual-store test
in the same file already relied on. The pre-existing hardcoded literal
a few tests up is changed too, so the file does not carry two
conventions for the same path.
- `makeAssertNoPnpNodeOptionsScript` was a copy of
`makeAssertNoPackageMapNodeOptionsScript` differing only in the
forbidden `NODE_OPTIONS` substring. Both are now
`makeAssertNoNodeOptionsScript(name, forbidden, marker)`.
Reported by Qodo.
|
Thanks — worked through the three findings in 8368c4f. Two applied, one declined as stale. AppliedHardcoded store version (Bug) — correct. Duplicate NODE_OPTIONS assertion helper (Rule violation) — correct. Declined: "No TypeScript test for PnP" (Rule 2255044)This one is stale — the mirrored TypeScript tests are already there, and were added two commits before the one the finding cites.
The underlying rule is a good one and I agree with it; it just does not apply here. Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit 8368c4f |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Follow-up on the "No TypeScript test for PnP" finding, which Qodo still lists after re-reviewing 8368c4f. I tried to close it the way it asked — a mirror of the Rust CLI-level test in Why it was abandoned. Notably my first version of that test passed with the guard removed — inert, because What the coverage actually is, and why I think it is sufficient:
Both fail with their own guard removed. The layer differs from the Rust tests, but the scenario is the same one. A real latent bug found on the way, worth its own change. Written by an agent (Claude Code, claude-opus-5). |
Picks up the install-module decomposition (#13640 and #13624), the headless-install extraction (#13637), the PnP-loader fix for virtual-store-only installs (#13636), and a dependency bump (#13631). `build_workspace_state` moved out of `install.rs` into the new `install/workspace_state.rs`, and its two call sites moved into `install/apply_materialization.rs` and `install/prepare_modules_state.rs`. This branch's `Sys: Clock` seam and the `::<Host>` turbofish are re-applied at those new homes. # Conflicts: # pnpm/crates/package-manager/src/install.rs
Summary
virtualStoreOnlypopulates the virtual store and creates no importer links — it is howpnpm fetchwarms a store in a Docker layer without touching the project. The importer symlinks andnode_modules/.package-map.jsonwere already skipped on that path, but.pnp.cjswas not..pnp.cjsis how a PnP project resolves, which makes it a project-level artifact of exactly the same kind. Writing it leaves the project claiming to resolve out of a store it was never linked into. This gates it onvirtualStoreOnlylike the other two.All four implementations carried the gap, so all four are fixed:
deps-installer/src/install/index.tsdeps-restorer/src/index.ts(reuses theskipPostImportLinkingflag it already derives)install_with_fresh_lockfile/linking.rsinstall_frozen_lockfile.rsWhy fix rather than forbid
Rejecting
virtualStoreOnly+nodeLinker: pnpas a config conflict was considered — there is precedent next door (CONFIG_CONFLICT_VIRTUAL_STORE_ONLY_WITH_NO_MODULES_DIR). It was rejected becausepnpm fetchsetsvirtualStoreOnlyitself, so erroring would stop PnP users warming a store at all, which is a legitimate thing to want.Tests
Two regression tests, each verified to fail when its own guard is removed:
fetch_under_pnp_does_not_write_the_loader— the frozen path.fetchpinsfrozenLockfile, so it always goes headless.virtual_store_only_install_under_pnp_does_not_write_the_loader— the fresh path, reachable becausevirtualStoreOnlyis apnpm-workspace.yamlsetting a plain install can carry.The second exists because the first does not exercise the fresh path at all; without it that guard would ship unexercised.
Both tests set the linker by appending to the harness's
pnpm-workspace.yaml. Overwriting it drops thestoreDir/cacheDir/registrythe harness put there, andnode-linkerin.npmrcdoes not enable PnP at all (pnpm 11 reads it from the workspace manifest) — either mistake yields a test that passes whatever the code does.Verification
cargo nextest run -p pacquet-package-manager— 857 passed.cargo nextest run -p pacquet-cli --test fetch --test install— 57 passed.-D warnings, andcargo docwithRUSTDOCFLAGS=-D warnings --document-private-items.The TypeScript half is not verified locally — the worktree has no
node_modules, sodeps-installer/deps-restorerwere neither typechecked nor tested. The edits are one-line conditionals, but CI is their first check. Flagging it rather than implying otherwise. The same missing bootstrap means the pre-push hook was inactive, so nothing was gated on push either.Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
pnpm fetchand virtual store-only installations with PnP enabled no longer generate.pnp.cjsloader files.Tests