Skip to content

fix(hoist): replace stale non-GVS symlinks when enable-global-virtual-store is toggled on - #12494

Merged
zkochan merged 5 commits into
pnpm:mainfrom
kairosci:fix/global-virtual-store-ts-type-inference
Jun 20, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
kairosci:fix/global-virtual-store-ts-type-inference

Conversation

@kairosci

@kairosci kairosci commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When enable-global-virtual-store is toggled on for a project that was previously installed without GVS, symlinkHoistedDependency silently skips replacing existing hoisted symlinks at node_modules/.pnpm/node_modules/<dep>. The isSubdir(virtualStoreDir, existingSymlink) check compares against storeDir/links (the GVS location), but stale symlinks from a prior non-GVS install point into node_modules/.pnpm/ — a path that is NOT a subdir of storeDir/links. The symlink is classified as "external" and left untouched, causing TypeScript to follow stale paths that may be incomplete or inconsistent.

This aligns with the existing dual-check pattern already used by safeIsInnerLink in installing/deps-resolver/src/safeIsInnerLink.ts:24-26.

Scope: This fixes the stale-symlink transition bug. The broader TypeScript type inference issue (#9739) is also related to the GVS architectural limitation described in #12437 — packages executing from the links store can't resolve transitive deps because Node's node_modules walk-up from storeDir/links/<hash>/node_modules/<pkg>/ never reaches the project's node_modules/. That requires a separate architectural fix.

Related: #12437, #9618, #9696

Squash Commit Body

fix(hoist): replace stale non-GVS symlinks when enable-global-virtual-store is toggled on

When a project transitions from non-GVS to GVS mode, hoisted symlinks at
`node_modules/.pnpm/node_modules/<dep>` still pointed into
`node_modules/.pnpm/<depPath>/node_modules/<dep>`. The
`symlinkHoistedDependency` function only checked `isSubdir(virtualStoreDir, ...)`
— with GVS active, `virtualStoreDir` is `storeDir/links`, so these old symlinks
were classified as "external" and silently skipped.

Added `internalPnpmDir` (derived from `path.dirname(privateHoistedModulesDir)`)
as a second check. Symlinks under `node_modules/.pnpm/` are now recognized as
pnpm-internal and correctly replaced, matching the pattern in `safeIsInnerLink`.

The broader TypeScript type inference breakage (#9739) also has an architectural
dimension: when TypeScript follows a symlink to storeDir/links/<hash>/, Node's
module resolution walk-up never reaches node_modules/. This is the same root
cause as #12437 (packages from links store can't resolve transitive deps) and
requires a separate architectural fix.

Closes pnpm/pnpm#9739

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, or the description notes what still needs porting.
  • 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.
  • Added or updated tests.
  • Updated the documentation if needed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved hoisted dependency symlink behavior when switching to Global Virtual Store, with safer handling of existing symlinks to ensure they’re correctly unlinked/relinked when their targets belong to the virtual store areas.
  • Tests

    • Added Jest coverage for transitioning from non-Global Virtual Store to Global Virtual Store, verifying hoisted symlink targets update as expected and that package.json files appear in both node_modules and the versioned Global Virtual Store links directory.

Copilot AI review requested due to automatic review settings June 18, 2026 11:49
@kairosci
kairosci requested a review from zkochan as a code owner June 18, 2026 11:49
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

symlinkHoistedDependency now receives an internalPnpmDir (parent of privateHoistedModulesDir) alongside virtualStoreDir. The external-symlink skip condition is expanded to allow relinking when the existing target lives under either directory. A new test verifies that switching a workspace to GVS mode correctly updates the hoisted symlink target.

Changes

GVS symlink conflict fix

Layer / File(s) Summary
Widen allowed-parent check in symlinkHoistedDependency
installing/linking/hoist/src/index.ts
Derives internalPnpmDir from privateHoistedModulesDir's parent, binds the helper with { virtualStoreDir, internalPnpmDir }, updates the parameter type, and expands the conflict-skip guard to accept targets under either virtualStoreDir or internalPnpmDir.
Test: non-GVS → GVS workspace switch
pnpm/test/install/globalVirtualStore.ts
Adds a test that installs without GVS, records the hoisted symlink target, re-installs with enableGlobalVirtualStore, and asserts the symlink now points into the GVS links directory with the correct package.json present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Suggested reviewers

  • zkochan
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix hoist: replace stale non-GVS symlinks when enabling global virtual store
🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Description

• Detect old hoisted symlinks pointing into non-GVS node_modules/.pnpm when GVS is enabled.
• Treat both GVS links dir and local pnpm dir as pnpm-internal for safe replacement.
• Add regression test for switching from non-GVS installs to GVS installs.
Diagram

graph TD
  A["pnpm install"] --> B["hoist/linker"] --> C["symlinkHoistedDependency"] --> D{"Target under\npnpm dirs?"}
  D -- "yes" --> E["unlink + relink"]
  D -- "no" --> F["skip (external)"]
  D -. "isSubdir" .-> G[("storeDir/links (GVS)")]
  D -. "isSubdir" .-> H[("node_modules/.pnpm")]

  subgraph Legend
    direction LR
    _proc["Process"] ~~~ _dec{"Decision"} ~~~ _dir[("Directory")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Share logic with deps-resolver `safeIsInnerLink`-style helper
  • ➕ Centralizes 'pnpm-internal link' detection to avoid drift across subsystems
  • ➕ Makes future directory heuristics (e.g., more pnpm internal roots) easier to update consistently
  • ➖ Requires factoring/shared dependency between hoist and deps-resolver layers
  • ➖ Bigger change footprint than a targeted bug fix
2. Derive internal roots from `.modules.yaml` virtualStoreDir metadata
  • ➕ Uses authoritative, per-project recorded virtual-store location(s) rather than path heuristics
  • ➕ Could handle more edge cases (nested installs, workspace roots) automatically
  • ➖ Not always readily available in this hoist call path
  • ➖ Adds IO/parsing and more moving parts for a small fix

Recommendation: The current approach is a good targeted fix: it mirrors the existing multi-root 'internal link' pattern (like safeIsInnerLink) while keeping the change small and low-risk. If this logic needs to expand again, consider extracting a shared utility to avoid duplicating internal-link heuristics across packages.

Files changed (2) +45 / -3

Bug fix (1) +6 / -3
index.tsTreat local '.pnpm' targets as internal when replacing hoisted symlinks +6/-3

Treat local '.pnpm' targets as internal when replacing hoisted symlinks

• Pass an additional 'internalPnpmDir' (derived from 'privateHoistedModulesDir') into 'symlinkHoistedDependency'. When an existing hoisted symlink target is under either the GVS links dir or the local '.pnpm' dir, it is now considered pnpm-internal and will be replaced rather than skipped as 'external'.

installing/linking/hoist/src/index.ts

Tests (1) +39 / -0
globalVirtualStore.tsAdd regression test for non-GVS → GVS migration symlink replacement +39/-0

Add regression test for non-GVS → GVS migration symlink replacement

• Adds a test that installs without GVS, verifies hoisted symlink targets point into '.pnpm', then enables GVS and reinstalls. The test asserts the hoisted symlink is repointed into 'storeDir/links' and verifies expected package files exist in the GVS structure.

pnpm/test/install/globalVirtualStore.ts

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.

Pull request overview

Fixes hoisted dependency symlink replacement when switching a project from the legacy per-project virtual store (node_modules/.pnpm) to the global virtual store (storeDir/links), ensuring stale hoisted links are recognized as pnpm-internal and overwritten instead of being treated as “external” and skipped.

Changes:

  • Extend symlinkHoistedDependency() to treat symlinks targeting the project’s internal .pnpm directory as pnpm-internal (in addition to the active virtualStoreDir) so they can be replaced during mode switches.
  • Add an end-to-end regression test covering the non-GVS → GVS transition and verifying that stale hoisted symlinks are updated.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pnpm/test/install/globalVirtualStore.ts Adds a regression test ensuring stale hoisted symlinks are replaced when toggling GVS on.
installing/linking/hoist/src/index.ts Updates hoist symlink replacement logic to also treat targets under the internal .pnpm dir as pnpm-internal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread installing/linking/hoist/src/index.ts Resolved
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Racey unlink can fail install 🐞 Bug ☼ Reliability
Description
In pacquet, update_stale_hoist_symlink treats failures from remove_symlink_dir() /
re-symlink_dir() as fatal; if another process removes dest between the readlink and unlink, the
hoist pass can fail with NotFound instead of recovering. This is inconsistent with pacquet’s own
force_symlink_dir logic, which explicitly ignores NotFound during unlink to tolerate concurrent
mutations.
Code

pacquet/crates/package-manager/src/hoist.rs[R620-631]

+    pacquet_fs::remove_symlink_dir(dest).map_err(|error| {
+        crate::SymlinkPackageError::SymlinkDir {
+            symlink_target: dep_dir.to_path_buf(),
+            symlink_path: dest.to_path_buf(),
+            error,
+        }
+    })?;
+    pacquet_fs::symlink_dir(dep_dir, dest).map_err(|error| crate::SymlinkPackageError::SymlinkDir {
+        symlink_target: dep_dir.to_path_buf(),
+        symlink_path: dest.to_path_buf(),
+        error,
+    })
Evidence
update_stale_hoist_symlink removes and recreates the link but does not tolerate
NotFound/concurrent mutation errors; pacquet’s own force_symlink_dir explicitly ignores
NotFound during unlink to handle parallel installers.

pacquet/crates/package-manager/src/hoist.rs[598-632]
pacquet/crates/fs/src/symlink_dir.rs[198-209]

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

## Issue description
`update_stale_hoist_symlink()` unconditionally propagates errors from `remove_symlink_dir(dest)` and `symlink_dir(dep_dir, dest)`. If `dest` is concurrently removed (or replaced) after the `read_symlink_dir(dest)` check, the install may fail instead of gracefully treating the link as already gone and continuing.
### Issue Context
Pacquet already implements a race-tolerant unlink + retry pattern in `pacquet_fs::force_symlink_dir` (it ignores `NotFound` during unlink).
### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[598-632]
- pacquet/crates/fs/src/symlink_dir.rs[198-209]
### Notes / Implementation guidance
- When `remove_symlink_dir(dest)` returns `NotFound`, treat it as a no-op (same as `force_symlink_dir`).
- Consider retrying `symlink_dir(dep_dir, dest)` if it returns `AlreadyExists` after removal (another process recreated it), by re-reading the link and re-evaluating whether it is stale/internal.
- Keep the conservative behavior for non-symlink occupants (leave as-is).

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



Remediation recommended

2. Extra path normalization overhead 🐞 Bug ➹ Performance
Description
update_stale_hoist_symlink normalizes paths multiple times per existing hoist link (equality check
plus two is_subdir calls, and is_subdir normalizes both inputs), adding avoidable CPU/alloc work
on warm installs where most symlink_dir calls hit AlreadyExists. This can become noticeable in
large hoisted graphs because the new introspection runs for every pre-existing hoist destination.
Code

pacquet/crates/package-manager/src/hoist.rs[R612-617]

+    if pacquet_fs::lexical_normalize(&existing) == pacquet_fs::lexical_normalize(dep_dir) {
+        return Ok(());
+    }
+    if !pacquet_fs::is_subdir(package_store_dir, &existing)
+        && !pacquet_fs::is_subdir(internal_pnpm_dir, &existing)
+    {
Evidence
The hoist path calls update_stale_hoist_symlink on AlreadyExists, and inside it performs a
lexical_normalize equality check plus two is_subdir checks; is_subdir itself normalizes both
inputs, causing repeated normalization allocations for the same values.

pacquet/crates/package-manager/src/hoist.rs[541-562]
pacquet/crates/package-manager/src/hoist.rs[612-617]
pacquet/crates/fs/src/is_subdir.rs[14-18]

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

## Issue description
`update_stale_hoist_symlink()` performs repeated lexical normalization for the same paths:
- It normalizes `existing` and `dep_dir` for equality.
- It then calls `is_subdir()` twice, which normalizes its arguments again.
On warm installs (common case), `symlink_dir()` returns `AlreadyExists` for most hoisted destinations, so this extra per-link work is executed at scale.
### Issue Context
`pacquet_fs::is_subdir()` is filesystem-free but allocates `PathBuf`s via `lexical_normalize()` for both arguments.
### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[541-632]
- pacquet/crates/fs/src/is_subdir.rs[14-18]
### Notes / Implementation guidance
- Normalize `existing` once (e.g., `existing_norm`) and normalize `dep_dir` once (`dep_norm`).
- For the subdir checks, either:
- normalize `package_store_dir` / `internal_pnpm_dir` once per `symlink_hoisted_dependencies` call and pass the normalized forms down, or
- add a small helper that does the prefix check against already-normalized values to avoid re-normalizing `existing` twice.
- Keep the current semantics (lexical, filesystem-free).

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


3. Malformed changeset content 🐞 Bug ⚙ Maintainability
Description
The new changeset includes stray ` and ` lines, which are not part of the repository’s standard
Changesets markdown format and will end up in the rendered changeset/release notes output. This
should be removed to keep release notes clean and avoid tooling surprises.
Code

.changeset/gvs-replace-stale-hoisted-symlinks.md[R7-8]

+</content>
+</invoke>
Evidence
The added changeset file includes two extra closing-tag lines after the human-readable note, unlike
other changesets in this repository which contain only frontmatter + markdown text.

.changeset/gvs-replace-stale-hoisted-symlinks.md[1-8]
.changeset/minimum-release-age-exclude-multi-entry.md[1-6]

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 new Changesets entry contains two stray XML-like closing tags (`</content>`, `</invoke>`). These are not used anywhere else in this repo’s `.changeset/*.md` files and will be treated as literal markdown content.
## Issue Context
Changesets files in this repo follow: YAML frontmatter, blank line, then plain markdown body.
## Fix Focus Areas
- .changeset/gvs-replace-stale-hoisted-symlinks.md[1-8]
## Suggested fix
Delete the two trailing lines:
- `</content>`
- `</invoke>`
Leave the rest of the changeset text intact.

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


4. Hoist relink churn 🐞 Bug ➹ Performance
Description
In pacquet, update_stale_hoist_symlink unlinks and recreates any existing pnpm-internal hoisted
symlink without checking whether it already points to dep_dir. This can cause unnecessary
unlink+relink I/O (and a transient missing-link window) on installs that run the hoist symlink pass,
even when links are already correct.
Code

pacquet/crates/package-manager/src/hoist.rs[R607-623]

+    if !pacquet_fs::is_subdir(package_store_dir, &existing)
+        && !pacquet_fs::is_subdir(internal_pnpm_dir, &existing)
+    {
+        return Ok(());
+    }
+    pacquet_fs::remove_symlink_dir(dest).map_err(|error| {
+        crate::SymlinkPackageError::SymlinkDir {
+            symlink_target: dep_dir.to_path_buf(),
+            symlink_path: dest.to_path_buf(),
+            error,
+        }
+    })?;
+    pacquet_fs::symlink_dir(dep_dir, dest).map_err(|error| crate::SymlinkPackageError::SymlinkDir {
+        symlink_target: dep_dir.to_path_buf(),
+        symlink_path: dest.to_path_buf(),
+        error,
+    })
Evidence
The new pacquet hoist logic calls update_stale_hoist_symlink on AlreadyExists; that helper only
checks whether the existing link points inside pnpm-managed directories and then always removes and
recreates the link, with no “already points to dep_dir” fast-path. pacquet_fs::symlink_dir is a
raw create operation (so existing links reliably hit the AlreadyExists branch), and pacquet_fs
explicitly notes that lacking an up-to-date comparison causes needless unlink+recreate cycles for
relative symlinks.

pacquet/crates/package-manager/src/hoist.rs[544-624]
pacquet/crates/fs/src/symlink_dir.rs[23-33]
pacquet/crates/fs/src/symlink_dir.rs[247-267]
pacquet/crates/package-manager/src/install_frozen_lockfile.rs[988-1008]

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

## Issue description
`update_stale_hoist_symlink()` removes and recreates a pnpm-internal hoisted symlink whenever the destination already exists, even if the existing symlink already resolves to the desired `dep_dir`. This adds avoidable filesystem churn in the hoist pass and introduces a small TOCTOU window where consumers could observe a missing link.
### Issue Context
- `symlink_hoisted_dependencies()` always attempts `pacquet_fs::symlink_dir()` first; when the destination already exists, this returns `AlreadyExists` and triggers `update_stale_hoist_symlink()`.
- `update_stale_hoist_symlink()` currently only checks whether the existing target is under `package_store_dir` or `internal_pnpm_dir`, then unconditionally unlinks and recreates.
- `pacquet_fs` already documents (in `existing_symlink_up_to_date`) that missing an equality check causes “every up-to-date relative symlink [to] read as stale and pays an unlink + recreate.”
### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[584-624]
Implement a fast-path in `update_stale_hoist_symlink()`:
1. Resolve the existing link target to an absolute path (you already compute `existing`).
2. If `lexical_normalize(existing)` equals `lexical_normalize(dep_dir)`, return `Ok(())` (already correct).
3. Only unlink/recreate when the target is pnpm-internal AND differs from `dep_dir`.
This preserves the intended “replace stale internal symlink” behavior while avoiding unnecessary relinks.

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


View more (1)
5. Brittle symlink target assert ✓ Resolved 🐞 Bug ☼ Reliability
Description
The new test assumes fs.readlinkSync() returns a string containing the absolute storeDir/links
path, but readlinkSync() returns the raw link target which can be relative. This can cause CI
flakiness or platform-dependent failures even when the behavior is correct.
Code

pnpm/test/install/globalVirtualStore.ts[R137-138]

+  const newTarget = fs.readlinkSync(depOfPkgWith1Dep)
+  expect(newTarget).toContain(path.join(storeDir, 'links'))
Evidence
The new test checks the raw readlinkSync() output for an absolute path, but existing tests
demonstrate the repo expects readlinkSync() results to often be relative and therefore resolves or
matches only relative segments.

pnpm/test/install/globalVirtualStore.ts[125-139]
installing/commands/test/link.ts[312-315]
installing/deps-installer/test/install/nodeRuntime.ts[213-215]

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

## Issue description
`fs.readlinkSync()` returns the symlink's stored target string, which may be relative. The test currently asserts that this raw string contains an absolute `storeDir/links` substring, which can fail depending on how the symlink was created.
### Issue Context
Other tests in this repo already treat `readlinkSync()` targets as potentially relative by either resolving them to an absolute path before comparison or asserting only on a relative segment.
### Fix Focus Areas
- pnpm/test/install/globalVirtualStore.ts[137-138]
### Suggested fix
Normalize the symlink target before asserting, e.g.:
- `const newTarget = fs.readlinkSync(depOfPkgWith1Dep)`
- `const newTargetAbs = path.resolve(path.dirname(depOfPkgWith1Dep), newTarget)`
- `expect(newTargetAbs).toContain(path.join(storeDir, 'links'))`
(Alternatively, use `resolveLinkTarget(depOfPkgWith1Dep)` if you prefer the existing helper used elsewhere.)

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



Informational

6. Hard-coded store version 🐞 Bug ⚙ Maintainability
Description
The new GVS transition test hard-codes the store layout version as "v11" when asserting the links
directory path. If STORE_VERSION changes, this test will fail even when behavior is correct, causing
avoidable maintenance churn.
Code

pnpm/test/install/globalVirtualStore.ts[R137-144]

+  const newTarget = path.resolve(path.dirname(depOfPkgWith1Dep), fs.readlinkSync(depOfPkgWith1Dep))
+  expect(newTarget).toContain(path.join(storeDir, 'v11', 'links'))
+
+  expect(fs.existsSync(path.resolve('node_modules/@pnpm.e2e/pkg-with-1-dep/package.json'))).toBeTruthy()
+  expect(fs.existsSync(path.resolve('node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep/package.json'))).toBeTruthy()
+
+  const globalVirtualStoreDir = path.join(storeDir, 'v11/links')
+  const files = fs.readdirSync(path.join(globalVirtualStoreDir, '@pnpm.e2e/pkg-with-1-dep/100.0.0'))
Evidence
The test uses literal "v11" in assertions/paths, while the store version is defined centrally as
STORE_VERSION = 'v11' and is used elsewhere to construct the same links path; this makes the new
test unnecessarily sensitive to future store version bumps.

pnpm/test/install/globalVirtualStore.ts[111-147]
core/constants/src/index.ts[7-11]
installing/commands/test/fetch.ts[189-200]

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 new test asserts paths containing a hard-coded store version string (`v11`). This will break tests when `@pnpm/constants` bumps `STORE_VERSION`, even if the implementation remains correct.
### Issue Context
The repo already centralizes the store version in `@pnpm/constants` as `STORE_VERSION` and other tests use it to build store paths.
### Fix Focus Areas
- pnpm/test/install/globalVirtualStore.ts[1-32]
- pnpm/test/install/globalVirtualStore.ts[111-148]
- core/constants/src/index.ts[7-11]
### Suggested fix
- Import `STORE_VERSION` from `@pnpm/constants` in `pnpm/test/install/globalVirtualStore.ts`.
- Replace hard-coded `'v11'` / `'v11/links'` with `STORE_VERSION`-based path building, e.g. `path.join(storeDir, STORE_VERSION, 'links')` (and similarly for the `toContain(...)` assertion).

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


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit e522299

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1c327d2

Copilot AI review requested due to automatic review settings June 18, 2026 15:55

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4f05bf0

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d94e00c

@zkochan

zkochan commented Jun 18, 2026

Copy link
Copy Markdown
Member

A test failed.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit cbe1a17

@kairosci

Copy link
Copy Markdown
Contributor Author

I fixed it.

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for changes in pacquet? If this is not an issue in pacquet at the moment, at least a test should be added.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

1 similar comment
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 247e628

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 03076c4

@codecov-commenter

codecov-commenter commented Jun 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.79487% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.14%. Comparing base (83457b5) to head (809ec04).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pacquet/crates/package-manager/src/hoist.rs 71.79% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12494      +/-   ##
==========================================
- Coverage   88.15%   88.14%   -0.01%     
==========================================
  Files         314      314              
  Lines       43514    43552      +38     
==========================================
+ Hits        38360    38390      +30     
- Misses       5154     5162       +8     

☔ 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.

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.805 ± 0.149 3.611 4.074 1.86 ± 0.12
pacquet@main 3.827 ± 0.172 3.627 4.046 1.87 ± 0.13
pnpr@HEAD 2.094 ± 0.143 1.967 2.349 1.02 ± 0.09
pnpr@main 2.051 ± 0.103 1.938 2.250 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.8048435882600002,
      "stddev": 0.14946373494057497,
      "median": 3.7705487677600003,
      "user": 3.63489288,
      "system": 3.4216334,
      "min": 3.61094028726,
      "max": 4.073740422259999,
      "times": [
        3.96221087626,
        3.78010929026,
        3.76098824526,
        3.89594228126,
        3.67696087326,
        3.89399218626,
        3.75959835526,
        3.63395306526,
        4.073740422259999,
        3.61094028726
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.8273328780599996,
      "stddev": 0.17168023528405282,
      "median": 3.76085583426,
      "user": 3.5742584799999997,
      "system": 3.457702200000001,
      "min": 3.62688685626,
      "max": 4.045746405259999,
      "times": [
        4.045746405259999,
        3.68933342926,
        3.7774503412600002,
        3.99085986526,
        4.02445255426,
        3.62688685626,
        3.6781090082600003,
        4.02163985126,
        3.67458914226,
        3.74426132726
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.09360401446,
      "stddev": 0.14282731986074923,
      "median": 2.03115847526,
      "user": 2.64738348,
      "system": 2.995445,
      "min": 1.96734428026,
      "max": 2.34889326426,
      "times": [
        1.96734428026,
        2.05090361826,
        2.15294578626,
        2.34453517826,
        2.01141333226,
        1.99690869926,
        2.05914853126,
        1.99538745926,
        2.34889326426,
        2.00855999526
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.0510560147600003,
      "stddev": 0.10321818778938684,
      "median": 2.0040448712599996,
      "user": 2.63984798,
      "system": 2.9858929000000005,
      "min": 1.9384249372600002,
      "max": 2.2497088182600002,
      "times": [
        2.16658176626,
        2.15933929226,
        2.2497088182600002,
        1.9599179902600001,
        1.9937652482600001,
        2.00345859926,
        2.0312737532600003,
        2.00356179926,
        2.00452794326,
        1.9384249372600002
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 650.7 ± 12.4 633.6 668.6 1.02 ± 0.03
pacquet@main 640.3 ± 17.6 625.4 680.1 1.00
pnpr@HEAD 679.5 ± 14.4 661.1 702.6 1.06 ± 0.04
pnpr@main 696.9 ± 26.8 667.3 745.3 1.09 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6506516566,
      "stddev": 0.012415805342675895,
      "median": 0.6462760169,
      "user": 0.3823714,
      "system": 1.3294539799999998,
      "min": 0.6336408389,
      "max": 0.6686085049,
      "times": [
        0.6686085049,
        0.6429382419,
        0.6437911099,
        0.6336408389,
        0.6399812679,
        0.6673628149,
        0.6411356059000001,
        0.6609716569,
        0.6487609239000001,
        0.6593256009
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6403462223,
      "stddev": 0.017586985592273115,
      "median": 0.6328828574,
      "user": 0.3755092,
      "system": 1.32430138,
      "min": 0.6254468429000001,
      "max": 0.6800960529000001,
      "times": [
        0.6274127129,
        0.6361336989,
        0.6266770349,
        0.6296320159000001,
        0.6439633169000001,
        0.6280675959,
        0.6254468429000001,
        0.6507695439000001,
        0.6552634079,
        0.6800960529000001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6795283753,
      "stddev": 0.014387170508805398,
      "median": 0.6798715659000001,
      "user": 0.3716487,
      "system": 1.3599263799999997,
      "min": 0.6611071279,
      "max": 0.7025966319,
      "times": [
        0.7025966319,
        0.6908764619000001,
        0.6886964879,
        0.6611071279,
        0.6624061369,
        0.6774580399000001,
        0.6822850919000001,
        0.6665610139,
        0.6938220769000001,
        0.6694746839000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6969372255999999,
      "stddev": 0.0268234143787486,
      "median": 0.6918519729,
      "user": 0.37961100000000003,
      "system": 1.3602281800000002,
      "min": 0.6673169759,
      "max": 0.7452706129000001,
      "times": [
        0.7452706129000001,
        0.6884920869000001,
        0.7412627629,
        0.6713316269,
        0.6926607199,
        0.7008525209,
        0.6745364049,
        0.6966053189,
        0.6673169759,
        0.6910432259
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.235 ± 0.034 4.196 4.288 1.97 ± 0.11
pacquet@main 4.215 ± 0.018 4.177 4.242 1.96 ± 0.11
pnpr@HEAD 2.174 ± 0.069 2.089 2.287 1.01 ± 0.07
pnpr@main 2.149 ± 0.122 2.002 2.426 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.23472601438,
      "stddev": 0.034186957636405564,
      "median": 4.230406481279999,
      "user": 3.71761798,
      "system": 3.42858254,
      "min": 4.19622834728,
      "max": 4.28759646328,
      "times": [
        4.19622834728,
        4.20627592228,
        4.28749984428,
        4.28759646328,
        4.25106519228,
        4.25146293028,
        4.23428660128,
        4.19871794728,
        4.20760053428,
        4.2265263612799995
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.215408580179999,
      "stddev": 0.01764722119193976,
      "median": 4.2177409057799995,
      "user": 3.7254428799999992,
      "system": 3.41312844,
      "min": 4.17709427328,
      "max": 4.242404307279999,
      "times": [
        4.242404307279999,
        4.21777703428,
        4.17709427328,
        4.20555384228,
        4.2020611062799995,
        4.215741192279999,
        4.228142076279999,
        4.21770477728,
        4.22091342428,
        4.22669376828
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.17351509028,
      "stddev": 0.068825262446067,
      "median": 2.1627061317800003,
      "user": 2.4969174799999996,
      "system": 2.95065664,
      "min": 2.0889950062800002,
      "max": 2.28723905428,
      "times": [
        2.17585112228,
        2.11265666228,
        2.11177684328,
        2.20664721828,
        2.28723905428,
        2.11561472628,
        2.14956114128,
        2.0889950062800002,
        2.25439526128,
        2.23241386728
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1487877745799997,
      "stddev": 0.12200385211356525,
      "median": 2.15719257628,
      "user": 2.48598068,
      "system": 2.9392431399999994,
      "min": 2.00207387928,
      "max": 2.4255191532800002,
      "times": [
        2.18234540928,
        2.00207387928,
        2.1744582012800002,
        2.04730783928,
        2.03534298328,
        2.4255191532800002,
        2.1995585492800003,
        2.0769607422800003,
        2.13992695128,
        2.20438403728
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.328 ± 0.012 1.311 1.349 2.02 ± 0.03
pacquet@main 1.332 ± 0.016 1.312 1.366 2.03 ± 0.04
pnpr@HEAD 0.688 ± 0.018 0.668 0.736 1.05 ± 0.03
pnpr@main 0.656 ± 0.009 0.643 0.670 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.32785765538,
      "stddev": 0.011995776128541222,
      "median": 1.3258456931799998,
      "user": 1.3188119400000002,
      "system": 1.7122707599999998,
      "min": 1.31121005518,
      "max": 1.34908398118,
      "times": [
        1.32111917718,
        1.3368380631799999,
        1.31577058118,
        1.32948359018,
        1.33753120818,
        1.3222077961799998,
        1.31852765618,
        1.3368044451799999,
        1.31121005518,
        1.34908398118
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3315111940799997,
      "stddev": 0.016000406848398263,
      "median": 1.32933255018,
      "user": 1.3195590400000001,
      "system": 1.7188579599999998,
      "min": 1.31212824218,
      "max": 1.36608166118,
      "times": [
        1.32386604518,
        1.33199572818,
        1.31332996618,
        1.31212824218,
        1.36608166118,
        1.33128190018,
        1.32738320018,
        1.34467039318,
        1.3234441451799999,
        1.3409306591799999
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6882106820800001,
      "stddev": 0.01824899524559501,
      "median": 0.6840439546800001,
      "user": 0.33855783999999994,
      "system": 1.32897356,
      "min": 0.6676414851800001,
      "max": 0.7360353311800001,
      "times": [
        0.6876551301800001,
        0.6774733901800001,
        0.6676414851800001,
        0.6804572361800001,
        0.7360353311800001,
        0.6819995511800001,
        0.6860883581800001,
        0.68151260018,
        0.6915496741800001,
        0.6916940641800001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6562619570800001,
      "stddev": 0.008687508738210203,
      "median": 0.65732256718,
      "user": 0.33994744,
      "system": 1.28691026,
      "min": 0.6428585101800001,
      "max": 0.6702508971800001,
      "times": [
        0.6492069291800001,
        0.6428585101800001,
        0.6594107131800001,
        0.65136269418,
        0.6468338451800001,
        0.6636537051800001,
        0.6643508491800001,
        0.6552344211800001,
        0.65945700618,
        0.6702508971800001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.985 ± 0.028 2.946 3.028 4.55 ± 0.09
pacquet@main 2.999 ± 0.051 2.967 3.140 4.57 ± 0.11
pnpr@HEAD 0.688 ± 0.009 0.673 0.703 1.05 ± 0.02
pnpr@main 0.657 ± 0.012 0.646 0.687 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.98549648322,
      "stddev": 0.02763222251549822,
      "median": 2.98307358802,
      "user": 1.7591933400000002,
      "system": 1.9589936799999996,
      "min": 2.9457607175200002,
      "max": 3.02825196752,
      "times": [
        3.02017816252,
        2.97563883452,
        2.97019687552,
        2.9617281755200002,
        2.9604113895200004,
        2.9457607175200002,
        3.01167485852,
        2.99050834152,
        2.9906155095200004,
        3.02825196752
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9994341431200007,
      "stddev": 0.05072498035707557,
      "median": 2.9861358420200004,
      "user": 1.75618524,
      "system": 1.9555640799999996,
      "min": 2.9668526345200004,
      "max": 3.13957028552,
      "times": [
        2.99500911952,
        2.9687502715200003,
        2.9668526345200004,
        2.9859329265200003,
        2.96999332852,
        3.00294139852,
        2.98376280552,
        2.99518990352,
        3.13957028552,
        2.9863387575200004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6879988524200001,
      "stddev": 0.008870881711665578,
      "median": 0.6876842900200001,
      "user": 0.34125754,
      "system": 1.32685978,
      "min": 0.6726936835200001,
      "max": 0.7028562325200001,
      "times": [
        0.6867186045200001,
        0.6795207275200001,
        0.6884141865200001,
        0.6891208495200001,
        0.6869543935200001,
        0.6939465345200001,
        0.7028562325200001,
        0.6980895245200001,
        0.6816737875200001,
        0.6726936835200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6565159750200001,
      "stddev": 0.011539370568852462,
      "median": 0.6558947990200001,
      "user": 0.33867314,
      "system": 1.2819822799999998,
      "min": 0.6458067685200001,
      "max": 0.6867153115200001,
      "times": [
        0.6503388485200001,
        0.6559812205200001,
        0.6867153115200001,
        0.6602863365200001,
        0.6458067685200001,
        0.6561346575200001,
        0.6558083775200001,
        0.6475577585200001,
        0.6503465205200001,
        0.6561839505200001
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12494
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,234.73 ms
(+0.21%)Baseline: 4,225.94 ms
5,071.13 ms
(83.51%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,985.50 ms
(-0.38%)Baseline: 2,997.02 ms
3,596.42 ms
(83.01%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,327.86 ms
(+0.12%)Baseline: 1,326.30 ms
1,591.57 ms
(83.43%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,804.84 ms
(-8.15%)Baseline: 4,142.28 ms
4,970.74 ms
(76.54%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
650.65 ms
(+5.04%)Baseline: 619.43 ms
743.31 ms
(87.53%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12494
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,173.52 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
688.00 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
688.21 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,093.60 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
679.53 ms
🐰 View full continuous benchmarking report in Bencher

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 473255d

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 473255d

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

…arget

update_stale_hoist_symlink removed and recreated the symlink even when it
already pointed at dep_dir, adding avoidable unlink + recreate I/O (and a
transient missing-link window) on warm reinstalls. Add an already-correct
fast path mirroring pacquet_fs::force_symlink_dir's existing_symlink_up_to_date.

Also add the changeset the original fix was missing.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

1 similar comment
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

Comment on lines +7 to +8
</content>
</invoke>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Malformed changeset content 🐞 Bug ⚙ Maintainability

The new changeset includes stray </content> and </invoke> lines, which are not part of the
repository’s standard Changesets markdown format and will end up in the rendered changeset/release
notes output. This should be removed to keep release notes clean and avoid tooling surprises.
Agent Prompt
## Issue description
A new Changesets entry contains two stray XML-like closing tags (`</content>`, `</invoke>`). These are not used anywhere else in this repo’s `.changeset/*.md` files and will be treated as literal markdown content.

## Issue Context
Changesets files in this repo follow: YAML frontmatter, blank line, then plain markdown body.

## Fix Focus Areas
- .changeset/gvs-replace-stale-hoisted-symlinks.md[1-8]

## Suggested fix
Delete the two trailing lines:
- `</content>`
- `</invoke>`

Leave the rest of the changeset text intact.

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 95b0dfe

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@zkochan
zkochan enabled auto-merge (squash) June 19, 2026 22:47
Comment on lines +620 to +631
pacquet_fs::remove_symlink_dir(dest).map_err(|error| {
crate::SymlinkPackageError::SymlinkDir {
symlink_target: dep_dir.to_path_buf(),
symlink_path: dest.to_path_buf(),
error,
}
})?;
pacquet_fs::symlink_dir(dep_dir, dest).map_err(|error| crate::SymlinkPackageError::SymlinkDir {
symlink_target: dep_dir.to_path_buf(),
symlink_path: dest.to_path_buf(),
error,
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Racey unlink can fail install 🐞 Bug ☼ Reliability

In pacquet, update_stale_hoist_symlink treats failures from remove_symlink_dir() /
re-symlink_dir() as fatal; if another process removes dest between the readlink and unlink, the
hoist pass can fail with NotFound instead of recovering. This is inconsistent with pacquet’s own
force_symlink_dir logic, which explicitly ignores NotFound during unlink to tolerate concurrent
mutations.
Agent Prompt
### Issue description
`update_stale_hoist_symlink()` unconditionally propagates errors from `remove_symlink_dir(dest)` and `symlink_dir(dep_dir, dest)`. If `dest` is concurrently removed (or replaced) after the `read_symlink_dir(dest)` check, the install may fail instead of gracefully treating the link as already gone and continuing.

### Issue Context
Pacquet already implements a race-tolerant unlink + retry pattern in `pacquet_fs::force_symlink_dir` (it ignores `NotFound` during unlink).

### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[598-632]
- pacquet/crates/fs/src/symlink_dir.rs[198-209]

### Notes / Implementation guidance
- When `remove_symlink_dir(dest)` returns `NotFound`, treat it as a no-op (same as `force_symlink_dir`).
- Consider retrying `symlink_dir(dep_dir, dest)` if it returns `AlreadyExists` after removal (another process recreated it), by re-reading the link and re-evaluating whether it is stale/internal.
- Keep the conservative behavior for non-symlink occupants (leave as-is).

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

Comment on lines +612 to +617
if pacquet_fs::lexical_normalize(&existing) == pacquet_fs::lexical_normalize(dep_dir) {
return Ok(());
}
if !pacquet_fs::is_subdir(package_store_dir, &existing)
&& !pacquet_fs::is_subdir(internal_pnpm_dir, &existing)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Extra path normalization overhead 🐞 Bug ➹ Performance

update_stale_hoist_symlink normalizes paths multiple times per existing hoist link (equality check
plus two is_subdir calls, and is_subdir normalizes both inputs), adding avoidable CPU/alloc work
on warm installs where most symlink_dir calls hit AlreadyExists. This can become noticeable in
large hoisted graphs because the new introspection runs for every pre-existing hoist destination.
Agent Prompt
### Issue description
`update_stale_hoist_symlink()` performs repeated lexical normalization for the same paths:
- It normalizes `existing` and `dep_dir` for equality.
- It then calls `is_subdir()` twice, which normalizes its arguments again.

On warm installs (common case), `symlink_dir()` returns `AlreadyExists` for most hoisted destinations, so this extra per-link work is executed at scale.

### Issue Context
`pacquet_fs::is_subdir()` is filesystem-free but allocates `PathBuf`s via `lexical_normalize()` for both arguments.

### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[541-632]
- pacquet/crates/fs/src/is_subdir.rs[14-18]

### Notes / Implementation guidance
- Normalize `existing` once (e.g., `existing_norm`) and normalize `dep_dir` once (`dep_norm`).
- For the subdir checks, either:
  - normalize `package_store_dir` / `internal_pnpm_dir` once per `symlink_hoisted_dependencies` call and pass the normalized forms down, or
  - add a small helper that does the prefix check against already-normalized values to avoid re-normalizing `existing` twice.
- Keep the current semantics (lexical, filesystem-free).

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 809ec04

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 31bd0fc

@zkochan
zkochan merged commit 1488db1 into pnpm:main Jun 20, 2026
28 checks passed
@kairosci
kairosci deleted the fix/global-virtual-store-ts-type-inference branch June 20, 2026 09:35
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.

4 participants