Repository navigation
fix: create global virtual store symlinks with native path separators on Windows - #12976
Conversation
There was a problem hiding this comment.
zkochan has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
PR Summary by QodoFix Windows GVS symlink creation by expanding
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
|
Warning Review limit reached
Next review available in: 32 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughGlobal virtual store path construction now expands slash-separated suffixes into native path components. Virtual store slot paths and config dependency directories use the shared helper, which is re-exported and covered by a platform-aware unit test. ChangesGlobal virtual store native path handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
916504e to
51a60f5
Compare
There was a problem hiding this comment.
zkochan has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
PR Code Suggestions ✨Warning
Explore these optional code suggestions:
|
||||||||||||||
… on Windows The global-virtual-store slot suffix is formatted as `@/<name>/<version>/<hash>` with `/` separators because it doubles as a cross-platform canonical id (it feeds hashing and lockfile comparison). Joining it onto the store dir with a plain `PathBuf::join` preserved those forward slashes on Windows, and they then reached `CreateSymbolicLinkW`, which rejects forward-slash paths with `ERROR_DIRECTORY` (os error 267) — aborting `pnpm install` on Windows whenever the global virtual store is enabled. Add a `join_global_virtual_store_path` helper that expands the `/`-separated suffix into native path components, and route the slot-path join sites through it (`VirtualStoreLayout::slot_dir` plus the two config-deps installer joins). No-op on Unix; produces `\` paths on Windows. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
51a60f5 to
2a6db32
Compare
There was a problem hiding this comment.
zkochan has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1. Changeset missing pnpm bump
|
| --- | ||
| "pacquet": patch | ||
| --- |
There was a problem hiding this comment.
1. Changeset missing pnpm bump 📘 Rule violation § Compliance
The new changeset only declares a version bump for pacquet and omits the required pnpm entry. This violates the repository changeset policy and may cause incorrect or incomplete release planning.
Agent Prompt
## Issue description
The changeset `.changeset/gvs-windows-separators.md` is missing a required `pnpm` front-matter entry.
## Issue Context
Per the changeset compliance rule, every changeset must explicitly declare a bump type for the `pnpm` package (`patch`/`minor`/`major`). This PR adds a changeset with only `"pacquet": patch`.
## Fix Focus Areas
- .changeset/gvs-windows-separators.md[1-3]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| pub fn join_global_virtual_store_path(base: &Path, rel: &str) -> PathBuf { | ||
| let mut path = base.to_path_buf(); | ||
| path.extend(rel.split('/')); | ||
| path |
There was a problem hiding this comment.
2. Nonsemver version breaks slots 🐞 Bug ≡ Correctness
join_global_virtual_store_path expands / into native components but does not ensure each resulting segment is Windows-valid, so a VersionPart::NonSemver like a tarball/git URL (contains : and /) can still produce an invalid/unexpected GVS slot path on Windows. This can abort installs when GVS is enabled and any dependency’s lockfile key uses a non-semver version string.
Agent Prompt
## Issue description
On Windows, the newly introduced `join_global_virtual_store_path` fixes `/` separators by splitting on `/`, but it still allows Windows-invalid characters and path-shaping substrings to survive in individual path components. In particular, `PkgVerPeer::VersionPart::NonSemver` is documented to preserve raw tarball/git URLs (which typically contain `:` and `/`). `gvs_version_segment` currently passes `NonSemver` through verbatim, so GVS slot paths can still become invalid on Windows (or gain extra path components from embedded `/`).
## Issue Context
- `VersionPart::NonSemver` preserves raw URL-like strings.
- `gvs_version_segment` passes `NonSemver` directly into the `<version>` segment, and the file already documents that `:` and embedded `/` are rejected by Windows.
- With this PR, Windows now reaches these code paths instead of failing earlier due to forward slashes.
## Fix Focus Areas
- pnpm/crates/package-manager/src/virtual_store_layout.rs[371-386]
- pnpm/crates/graph-hasher/src/global_virtual_store_path.rs[147-165]
### Suggested fix
Prefer fixing at the source of the `<version>` segment:
- Update `gvs_version_segment` so `VersionPart::NonSemver(_)` does **not** flow verbatim into the filesystem path. For example:
- map `NonSemver(_)` to a stable safe string like `"undefined"` / `"nonsemver"`, **or**
- map to a deterministic encoded form (e.g., replace Windows-invalid characters, or use a short hash suffix) so it stays Windows-safe without exploding path depth.
Optionally add/extend a unit test to cover a NonSemver version containing `https://...` and assert the resulting slot dir contains no `:` and does not gain extra components from the URL’s `/`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Micro-Benchmark ResultsLinux |
The windows Rust job fails in its setup install: the published pnpm v12.0.0-alpha.9 predates the mixed-separator store symlink fix (pnpm#12976), so cold-cache runners hit it. Main's latest run passed the same step on a warm cache — retriggering for another roll until an alpha carrying the fix is published. Co-Authored-By: Claude Fable 5 <[email protected]>
The windows Rust job fails in its setup install: the published pnpm v12.0.0-alpha.9 predates the mixed-separator store symlink fix (pnpm#12976), so cold-cache runners hit it. Main's latest run passed the same step on a warm cache — retriggering for another roll until an alpha carrying the fix is published. Co-Authored-By: Claude Fable 5 <[email protected]>
The windows Rust job fails in its setup install: the published pnpm v12.0.0-alpha.9 predates the mixed-separator store symlink fix (pnpm#12976), so cold-cache runners hit it. Main's latest run passed the same step on a warm cache — retriggering for another roll until an alpha carrying the fix is published. Co-Authored-By: Claude Fable 5 <[email protected]>
A scoped dependency's node_modules/@scope/name link path is built by joining the whole @scope/name alias as one segment. Rust's Path::join appends segments verbatim (unlike Node's path.join, which normalizes), so the / inside the alias survived into an otherwise \-separated Windows path and reached CreateSymbolicLinkW, which rejects forward-slash paths — the long store paths reach it in verbatim \\?\ form where / is a literal filename byte — with ERROR_DIRECTORY (os error 267), aborting the install. This is the same failure class as the global-virtual-store slot-path fix in #12976, which normalized the slot suffix at its construction sites. Rather than chase every join site, rewrite paths to native separators at the symlink writer's own choke points: symlink_dir (covering the hoisted linker's direct calls) and force_symlink_dir's entry (so its read_link / remove_dir / rename / create_dir_all retry steps all see a native path too). The rewrite only allocates when a / is actually present and is a no-op on Unix. The TypeScript CLI is unaffected: Node's path.join already normalizes separators on Windows, so no counterpart change is needed.
The windows Rust job fails in its setup install: the published pnpm v12.0.0-alpha.9 predates the mixed-separator store symlink fix (pnpm#12976), so cold-cache runners hit it. Main's latest run passed the same step on a warm cache — retriggering for another roll until an alpha carrying the fix is published. Co-Authored-By: Claude Fable 5 <[email protected]>
The windows Rust job fails in its setup install: the published pnpm v12.0.0-alpha.9 predates the mixed-separator store symlink fix (pnpm#12976), so cold-cache runners hit it. Main's latest run passed the same step on a warm cache — retriggering for another roll until an alpha carrying the fix is published. Co-Authored-By: Claude Fable 5 <[email protected]>
Problem
pnpm install(pacquet engine) aborts on Windows whenever the global virtual store is enabled — which brokeRust CI / Test / windowsonmainand every PR:Note the separators in that path: native
\up to…\links, then forward slashes for the rest.Root cause
The global-virtual-store slot suffix is produced by
format_global_virtual_store_pathas@/<name>/<version>/<hash>, which always uses/because it doubles as a cross-platform canonical id (it feeds hashing and lockfile comparison). It was joined onto the store dir with a plainPathBuf::join, which preserves/on Windows. Those forward slashes then reachedCreateSymbolicLinkW, and Windows' reparse-point APIs reject forward-slash paths withERROR_DIRECTORY(os error 267). The junction fallback only kicks in onPermissionDenied, so a 267 propagated straight up.Unix is unaffected because
/is already the native separator — which is why only Windows broke.Fix
Add a
join_global_virtual_store_path(base, rel)helper that expands the/-separated suffix into native path components, and route the slot-path join sites through it:VirtualStoreLayout::slot_dir— the choke point every symlink target/link path flows throughinstall_config_deps.rsNo-op on Unix; produces
\paths on Windows. Covered by a new unit test ingraph-hasher; existingslot_dir/env-installer tests still pass.🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit