Repository navigation
fix(store.path): keep the store inside the project when nothing above it is linkable - #13536
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughStore resolution now places the store under ChangesStore path selection
Estimated code review effort: 3 (Moderate) | ~20 minutes Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 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 |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (5): Last reviewed commit: "fix(store.path): compare the mountpoint ..." | Re-trigger Greptile |
… it is linkable `dirsAreEqual` compared the result of `path.relative()` with `'.'`, but Node returns `''` for equal paths, so both equality checks in `storePathRelativeToHome` were always false. The dead branch would have placed the store in the home directory whenever the project folder was the only linkable location. Executing that branch would be the wrong trade. It fires exactly when no ancestor of the project accepts a hard link — an agent sandbox that grants write access only to the project, or a container with just the project bind-mounted writable. There the home store is either read-only, so the install fails outright, or on another volume, so every package is copied instead of hard linked and nothing is ever reused. A store on the project's own volume is the better answer in both cases, so the branch is removed rather than repaired, and the surviving root guard drops the helper for a plain string comparison of two `path.join` results. pacquet implemented the intended-but-dead branch, so it inherited both failure modes; it now keeps the store in the project too. It places the store at `<project>/node_modules/.pnpm-store` instead of pnpm 11's `<project>/.pnpm-store`, which keeps it out of the working tree's VCS status. The install purge already skips hidden entries other than `.bin`, `.modules.yaml`, and the virtual store dir, so a layout change cannot wipe the store; `test_install_purges_node_modules_on_layout_mismatch` now pins that. Closes pnpm#13525
fe6c862 to
fe4dd2b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
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/package-manager/src/install/tests.rs`:
- Around line 10079-10084: Update the purge regression test around the two
install configurations so both installs use the nested node_modules store path
represented by store_in_modules, then create a marker file with known content
there before the second install. Replace the directory-only exists assertion
with a read-and-compare assertion that verifies the marker content remains after
purging, covering both affected test locations.
In `@pnpm11/store/path/src/index.ts`:
- Around line 62-68: Align the project-root store layout with pacquet’s
<pkg_root>/node_modules/.pnpm-store contract instead of returning
<pkg_root>/.pnpm-store/v11. Update the mountpoint return logic in
pnpm11/store/path/src/index.ts, the corresponding store-path logic and related
test expectations in pnpm/crates/config/src/store_path.rs (lines 23-30 and
100-103) and pnpm/crates/config/src/store_path/tests.rs (lines 146-157), and
update the Rust documentation and changeset to describe the shared layout.
🪄 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: f2c6a6ed-6505-47dc-9e29-907f9444a7fc
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (7)
.changeset/sandbox-store-path.mdpnpm/crates/config/src/store_path.rspnpm/crates/config/src/store_path/tests.rspnpm/crates/package-manager/src/install/tests.rspnpm11/store/path/package.jsonpnpm11/store/path/src/index.tspnpm11/store/path/test/index.ts
💤 Files with no reviewable changes (1)
- pnpm11/store/path/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
- .changeset/sandbox-store-path.md
- pnpm11/store/path/test/index.ts
The comment on the mountpoint return claimed the home store "would have to be copied from", which is only true once the project is on a volume of its own — on a dev machine a home store is often the better place, and the reason this code doesn't pick it is the sandbox and CI cases, not a blanket rule. Drop it: the store-path tests already pin which directory wins. Trim the pacquet module docs to the one fact a reader can't recover from the code — that nesting the store under `node_modules` is a deliberate divergence from pnpm 11 — and drop the inline restatements of it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13536 +/- ##
==========================================
+ Coverage 88.08% 88.09% +0.01%
==========================================
Files 608 608
Lines 99032 99032
==========================================
+ Hits 87231 87241 +10
+ Misses 11801 11791 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review by Qodo
1. No mirrored store-path tests
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
The purge regression test created an empty `node_modules/.pnpm-store` and asserted only that the directory existed afterwards, so a purge that deleted and recreated it would still pass. `store_dir` also pointed outside `node_modules`, leaving the directory unrelated to the store the assertion was about. Both installs now use `<modules_dir>/.pnpm-store` as their store, and a marker file written before the second install has to come back with its contents intact.
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Code review by qodo was updated up to the latest commit 20286fe |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…tive A string comparison of the two paths assumes both are already normalized the same way, which holds only as long as `rootLinkTarget` returns a resolved path. `path.relative` does not depend on that, and on Windows it compares case-insensitively, so `C:\Foo` and `c:\foo` are recognized as the same directory.
|
Code review by qodo was updated up to the latest commit 4c97241 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Summary
Closes #13525.
dirsAreEqualcompared the result ofpath.relative()with'.', but Node returns''for equal paths, so both equality checks instorePathRelativeToHomewere always false. The dead branch would have placed the store in the home directory whenever the project folder was the only linkable location.The original version of this PR repaired the comparison. Measuring the result showed that executing the branch is the wrong trade, so this PR now removes it instead.
The branch fires exactly when no ancestor of the project accepts a hard link — an agent sandbox that grants write access only to the project, or a container with just the project bind-mounted writable. In a read-only-root sandbox (
bwrap --ro-bind / /with only the project writable):<project>/.pnpm-store(what pnpm has always shipped)~/.local/share/pnpm/store/v11(repairing the comparison)EROFS ... symlink .../store/v11/projects/38f7f...When the home directory is writable, it is on another volume by construction — that is why the earlier
canLinkprobe failed — so the home store forces a full copy of every package and reuses nothing, which is the worst outcome in CI. A store on the project's own volume is the better answer in both cases.So: the dead branch is removed rather than repaired, and the surviving root guard drops the helper for a plain string comparison of two
path.joinresults. The TypeScript CLI's behavior does not change — it is what pnpm has shipped since@pnpm/store-pathmoved into the monorepo.pacquet
pacquet implemented the intended-but-dead branch, so it inherited both failure modes. It now keeps the store in the project too, at
<project>/node_modules/.pnpm-storerather than pnpm 11's<project>/.pnpm-store, which keeps it out of the working tree's VCS status — the complaint in #13525. This is a deliberate divergence between the two stacks, documented in thestore_pathmodule docs.The install purge skips hidden entries other than
.bin,.modules.yaml, and the virtual store dir, so a layout change cannot wipe a store nested there;test_install_purges_node_modules_on_layout_mismatchnow pins that.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.
Validation
pnpm --filter @pnpm/store.path test— 5/5cargo nextest run -p pacquet-config— 453/453cargo nextest run -p pacquet-package-manager test_install_purges_node_modules_on_layout_mismatch— pass, and verified non-vacuous by disabling the purge's hidden-entry skipcargo fmt --check,cargo clippy -D warningson the touched crates,RUSTDOCFLAGS=-D warnings cargo doc -p pacquet-configpnpm run lint:meta, cspell,pnpm install --frozen-lockfilemain; the unusedis-windowsdevDependencies the test rewrite orphaned were removed along with their lockfile entriesWritten by an agent (Claude Code, claude-opus-5[1m]).
Summary by CodeRabbit
Bug Fixes
<project>/node_modules/.pnpm-storeinstead of falling back to the home directory.Tests