Skip to content

fix(resolving-deps-resolver): hoist a local root dep by its version, not its path - #13387

Merged
zkochan merged 4 commits into
mainfrom
fix-13373
Jul 26, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix-13373

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Under resolvePeersFromWorkspaceRoot, the workspace root's direct dependencies are the first candidates for another importer's missing peer, and the hoist copies the root's specifier string into that importer and re-resolves it there. So the specifier has to mean the same thing from a different directory — and link:, file:, and the path form of workspace: do not.

Demonstrated on the TypeScript side before the fix, with a root ajv: link:ajv-local and a sibling pkg needing ajv as a peer:

pkg importer         : {"ajv-keywords":{"version":"1.5.0(ajv@pkg+ajv-local)"}}
pkg/node_modules/ajv ->  ../ajv-local
  target resolves to  :  /…/pkg/ajv-local
  target EXISTS?      :  false        ← dangling symlink

Both stacks now substitute the linked package's own version for its path. The root keeps the authority over the peer that it already has when it declares the package with a version range — a sibling's newer copy no longer wins over the version the root pins — and the peer resolves to the same package from every importer:

root declares sibling has peer the importer gets
ajv: 4.10.0 ajv: 5.0.0 [email protected] (unchanged)
ajv: link:ajv-local (its manifest says 4.10.0) ajv: 5.0.0 [email protected] (was a dangling link)

The manifest is read from disk rather than taken from the resolved dependency, because a linked dep reused from the lockfile has no resolved address (resolveDependencies.ts short-circuits depIsLinked deps) — reading it keeps a repeat install hoisting what a fresh install of the same manifest hoists. A target with no manifest to read (a file: tarball, a path that does not exist) or no valid version in it is not a candidate, and the peer falls through to the ordinary auto-install path.

A workspace: range needs none of this — it selects the same workspace package from every importer, so it is hoisted as-is. pacquet previously dropped it (is_project_relative_specifier excluded all of workspace:) and resolved a second copy off the registry for a peer the root already provided from the workspace.

The same candidate list bounds optional-peer hoisting, so getHoistableOptionalPeers / get_hoistable_optional_peers pick up the rule with no change of their own — this closes the asymmetry a reviewer raised on #13369.

Closes #13373.

Squash Commit Body

A workspace-root dependency declared with link:, file:, or the path form
of workspace: names a directory relative to the root, so hoisting the
specifier verbatim re-resolved it against the directory of the importer
the peer was hoisted into: a root `link:ajv-local` reached pkg/ajv-local
and left a dangling symlink there.

Both stacks now substitute the linked package's own version for its path.
The root keeps the authority over the peer that it has when it declares
the package with a version range — a sibling's newer copy no longer wins
over the version the root pins — and the peer resolves to the same
package from every importer. The manifest is read from disk rather than
taken from the resolved dependency, which a linked dep reused from the
lockfile does not have; reading it keeps a repeat install hoisting what a
fresh install of the same manifest hoists. A target with no manifest to
read (a file: tarball, a path that does not exist) or no valid version in
it is not a candidate, and the peer falls through to the ordinary
auto-install path.

A workspace: range needs none of this: it selects the same workspace
package from every importer, so it is hoisted as-is. pacquet previously
dropped it and resolved a second copy off the registry for a peer the
root already provided from the workspace.

The same candidate list bounds optional-peer hoisting, so
getHoistableOptionalPeers picks up the rule with no change of its own.

Closes pnpm/pnpm#13373.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ 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.

Tests

Each new test was verified to fail when the behavior is reverted.

  • TypeScript (installing/deps-installer/test/install/peerDependencies.ts): a link: root dep pinning the peer at its own version, a link: target with no manifest to read, and a workspace: range case. Full @pnpm/installing.deps-installer suite green (80 suites / 828 tests); @pnpm/installing.deps-resolver green (155 tests).
  • Rust (resolve_workspace/tests.rs): a_link_root_dep_provides_the_peer_at_the_linked_packages_version, a_workspace_path_root_dep_is_not_offered_as_a_peer_provider, and a_workspace_range_root_dep_is_offered_as_a_peer_provider. Full workspace suite green (7193 tests); cargo fmt, taplo format --check, workspace clippy, and rustdoc clean.

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved workspace peer dependency resolution for link:, file:, and path-based workspace: references, ensuring peers are sourced from the correct package version/context.
    • Prevented project-relative workspace-root dependencies from being incorrectly reused across workspace projects.
    • Kept correct peer resolution behavior for version-based workspace: ranges.
    • Improved error handling when a workspace-root manifest can’t be read during peer resolution.
  • Tests

    • Expanded coverage for project-relative and workspace-range peer dependency scenarios, including lockfile version assertions and peer warning behavior.

…s importer-independent

Under resolvePeersFromWorkspaceRoot, the workspace root's direct
dependencies are the first candidates for another importer's missing
peer. Which of them may stand in differed between the two stacks: the
TypeScript CLI applied no filter at all, while pacquet dropped every
link:, file:, and workspace: specifier.

Both now use the same rule. link: and file: — and the path form of
workspace: (workspace:./pkg, workspace:../pkg) — name a directory
relative to the project that declares them, so hoisting one into a
sibling importer re-resolves it against that importer's directory and
reaches a different path, or none: a root `link:ajv-local` became
`ajv@pkg+ajv-local` for the importer it was hoisted into, a link
pointing at a directory that does not exist. Those are dropped in both
stacks. A workspace: range (workspace:^8.5.10) is not path-relative —
it selects the same workspace package from every importer — so it stays
a candidate in both stacks, and pacquet no longer resolves a second copy
off the registry for a peer the root already provides from the
workspace.

The same candidate list bounds optional-peer hoisting, so
getHoistableOptionalPeers picks up the rule with no change of its own.

Closes #13373.
Copilot AI review requested due to automatic review settings July 25, 2026 23:25

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 reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The resolver pins project-relative link:, file:, and path-based workspace: root dependencies to local manifest versions, propagates manifest errors, and retains range-based workspace: dependencies as peer providers. Rust and installer tests cover these behaviors.

Changes

Workspace peer hoisting

Layer / File(s) Summary
Specifier classification and manifest-based pinning
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs, pnpm11/installing/deps-resolver/src/resolveDependencies.ts
Project-relative root dependencies are detected, local manifests are read, and normalized specifiers are pinned to target versions or cleared when unavailable.
Resolver and installer error propagation
pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs, pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
Manifest-reading failures propagate through workspace resolution and map to a dedicated installer error.
Peer-resolution validation and release metadata
pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs, pnpm11/installing/deps-installer/test/install/peerDependencies.ts, .changeset/peer-hoist-skips-project-relative-root-deps.md
Tests cover project-relative non-providers, linked-package versions, missing manifests, and workspace-range providers; release notes document the behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WorkspaceImporter
  participant LocalPackageManifest
  participant PeerResolution
  participant Installer
  WorkspaceImporter->>LocalPackageManifest: read project-relative dependency manifest
  LocalPackageManifest-->>WorkspaceImporter: return package version or manifest error
  WorkspaceImporter->>PeerResolution: pass pinned root dependency
  PeerResolution-->>Installer: resolve peer dependency tree
Loading

Possibly related issues

  • pnpm/pnpm#13373 — Concerns distinguishing project-relative specifiers from workspace-range peer providers.
  • pnpm/pnpm#13351 — Also concerns workspace-root dependency normalization in build_workspace_root_deps.

Possibly related PRs

  • pnpm/pnpm#13343 — Also modifies workspace-root peer-hoisting and hoistable dependency propagation.

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

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13373

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix peer hoisting: ignore project-relative root specs (link/file/workspace:./)

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Align peer-hoisting candidate rules across TypeScript CLI and pacquet.
• Skip root deps with importer-relative specifiers (link:, file:, workspace:./../) when hoisting
 peers.
• Add regression tests for link: and workspace: range behavior under resolvePeersFromWorkspaceRoot.
Diagram

graph TD
  A["Workspace root deps"] --> B{"Importer-independent?"} --> C["Hoistable peer candidates"] --> D["Peer resolution"] --> E["Peers + lockfile graph"]
  T["TS deps-resolver"] --> B
  R["Rust resolving-deps-resolver"] --> B
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Rewrite project-relative specifiers when hoisting
  • ➕ Could preserve hoisting for link:/file:/workspace:./ by rebasing paths to the consuming importer
  • ➕ Avoids losing a potential peer provider in some edge cases
  • ➖ Hard to do correctly across protocols and platforms (path normalization, symlinks, workspace layout)
  • ➖ Changes semantics: the hoisted specifier becomes a different string than declared in the root
  • ➖ Higher risk of subtle resolution bugs than simply refusing these candidates
2. Resolve to an absolute/opaque directory resolution id before hoisting
  • ➕ Could keep “same target directory” semantics without string rewriting
  • ➕ May align better with lockfile-level resolution types (DirectoryResolution)
  • ➖ Requires larger refactor of candidate representation and equality logic
  • ➖ May leak implementation details across layers and complicate serialization/lockfile behavior

Recommendation: Keep the PR’s approach: only hoist root peer providers whose specifier is importer-independent. It is the safest correctness fix (prevents broken link/file/workspace path re-resolution) and matches the intended meaning of “root provides peer to others” without introducing path-rewrite complexity.

Files changed (5) +246 / -20

Bug fix (2) +27 / -11
resolve_importer.rsTreat only workspace path-form as project-relative in Rust peer hoisting +7/-5

Treat only workspace path-form as project-relative in Rust peer hoisting

• Updates the project-relative specifier predicate to exclude only workspace path-form (workspace:.) rather than all workspace: specifiers. Expands comments to clarify that workspace ranges are importer-independent and remain eligible as peer providers.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs

resolveDependencies.tsFilter hoistable root peer candidates by importer-independent specifiers (TS) +20/-6

Filter hoistable root peer candidates by importer-independent specifiers (TS)

• Updates getHoistableRootDeps to drop normalized and wanted specifiers that are project-relative (link:, file:, workspace:./..). Introduces an explicit isProjectRelativeSpecifier helper documenting the rule and keeping behavior aligned with the Rust implementation.

pnpm11/installing/deps-resolver/src/resolveDependencies.ts

Tests (2) +212 / -9
tests.rsAdd/extend Rust tests for workspace path vs range peer-provider behavior +110/-9

Add/extend Rust tests for workspace path vs range peer-provider behavior

• Refactors the shared helper to accept an arbitrary local specifier and adds a new test ensuring workspace path-form root deps are not offered as peer providers. Introduces a new test asserting workspace range-form root deps do satisfy peers and prevent fetching a second registry copy.

pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs

peerDependencies.tsAdd pnpm integration tests for link: and workspace: range peer resolution +102/-0

Add pnpm integration tests for link: and workspace: range peer resolution

• Adds a regression test showing that a root link: dependency should not be used to satisfy a sibling importer’s peer (avoiding broken relative link targets). Adds a test verifying that a workspace:^ range in the root does satisfy peer requirements without reporting peer issues.

pnpm11/installing/deps-installer/test/install/peerDependencies.ts

Documentation (1) +7 / -0
peer-hoist-skips-project-relative-root-deps.mdDocument peer-hoisting rule change for project-relative root deps +7/-0

Document peer-hoisting rule change for project-relative root deps

• Adds a changeset entry explaining that link:, file:, and workspace path-form root deps no longer satisfy peers in other workspace projects, while workspace range-form still can. Includes rationale and links the fixed issue.

.changeset/peer-hoist-skips-project-relative-root-deps.md

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported versionless-path issue is addressed by clearing the candidate before manifest validation, and downstream peer selection excludes candidates without a normalized specifier.

Reviews (4): Last reviewed commit: "style(resolving-deps-resolver): add the ..." | Re-trigger Greptile

@qodo-code-review

qodo-code-review Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Unbounded manifest read fanout 🐞 Bug ➹ Performance
Description
getHoistableRootDeps() now runs Promise.all() across all root deps and for each project-relative
dep may read package.json; in large workspaces this can create excessive concurrent file reads and
cause IO contention or EMFILE-style failures. This affects the install hot path when
resolvePeersFromWorkspaceRoot is enabled.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R548-553]

+  return Promise.all(rootDeps.map(async (rootDep) => {
+    if (rootDep.normalizedBareSpecifier == null || !isProjectRelativeSpecifier(rootDep.normalizedBareSpecifier)) {
+      return rootDep
+    }
+    return pinProjectRelativeDepToItsVersion(rootDep, rootDir)
+  }))
Relevance

⭐⭐ Medium

Concurrency limiting is plausible, but repo has accepted Promise.all fanout patterns; unclear if
they’ll cap manifest reads.

PR-#12491
PR-#12855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new implementation explicitly wraps the per-dep pinning (which reads package.json) in a
Promise.all, causing all qualifying manifest reads to start concurrently.

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-605]
pnpm11/pkg-manifest/reader/src/index.ts[39-50]

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

## Issue description
`getHoistableRootDeps()` uses `Promise.all(rootDeps.map(...))` and each project-relative dep can trigger a manifest read from disk. This creates unbounded concurrency proportional to the number of root deps.

## Issue Context
The fan-out only happens when `resolvePeersFromWorkspaceRoot` is enabled and only for root deps whose specifier is `link:`/`file:`/`workspace:.`, but in large workspaces the root can still have many such deps.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-604]

## Suggested fix
- Use a concurrency limiter (the repo already uses `p-limit` elsewhere) to bound simultaneous `safeReadPackageJsonFromDir()` calls (e.g. 8–16).
- Optionally dedupe reads by resolved directory path to avoid reading the same manifest multiple times if aliases point to the same target.

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


2. Blocking manifest reads 🐞 Bug ➹ Performance
Description
The resolver now reads workspace-root local dependency manifests via synchronous filesystem I/O
during dependency resolution, which can block async executor threads and slow installs on large
workspaces or slow filesystems. This work is triggered specifically for root
link:/file:/workspace:. deps when building the hoistable root-dep candidate list.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R791-803]

+/// [`safe_read_package_json_from_dir`] maps only a missing file to
+/// `Ok(None)`; a `file:` target is a tarball as often as a directory, and
+/// a path component of a tarball is not a directory to read a manifest
+/// from.
+fn read_manifest_of_local_target(
+    dir: &Path,
+) -> Result<Option<serde_json::Value>, PackageManifestError> {
+    match safe_read_package_json_from_dir(dir) {
+        Err(PackageManifestError::Io(err)) if err.kind() == io::ErrorKind::NotADirectory => {
+            Ok(None)
+        }
+        result => result,
+    }
Relevance

⭐⭐ Medium

Team accepts hot-path perf improvements, but no clear precedent on replacing sync manifest reads
with nonblocking IO.

PR-#13172
PR-#13359

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new pinning path reads local targets’ manifests, and the underlying helper performs synchronous
fs::read_to_string, so this adds blocking disk I/O to the resolver’s install-time flow.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-804]
pnpm/crates/package-manifest/src/lib.rs[837-850]

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

## Issue description
`read_manifest_of_local_target()` calls `safe_read_package_json_from_dir()`, which uses `std::fs::read_to_string`. This synchronous disk I/O now happens on the dependency-resolution hot path when pinning project-relative root deps, potentially blocking Tokio worker threads.

## Issue Context
This path is reached from `build_workspace_root_deps()` when a workspace root dep’s specifier is `link:`/`file:`/`workspace:.` and the code tries to pin it to the linked package’s version.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[760-803]
- pnpm/crates/package-manifest/src/lib.rs[837-850]

## Suggested fix
- Either:
 - Introduce an async variant of `safe_read_package_json_from_dir` (using `tokio::fs`) and make the pinning path async; or
 - Wrap the manifest read/parse in `tokio::task::spawn_blocking` (or equivalent) so the synchronous read doesn’t block executor threads.
- Consider short-circuiting when the version is already known safely (only if you can prove it’s not a synthetic placeholder).

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



Informational

3. Absolute local deps mis-hoisted 🐞 Bug ⛨ Security ⭐ New
Description
When a workspace-root dep uses an absolute file:/link: target, build_workspace_root_deps()
still treats it as “project-relative” and replaces the specifier with the target manifest’s semver
version. This can cause peer hoisting to resolve name@version from the registry (or fail if
unpublished) instead of using the intended absolute local path provider.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R860-874]

+        // Cloned so the identity can be written back onto `dep`; only the
+        // handful of root deps declared with a local protocol reach here.
+        let Some(spec) = dep.normalized_bare_specifier.clone() else { continue };
+        if !is_project_relative_specifier(&spec) {
+            continue;
+        }
+        // A path is never hoistable, so a target that names no version to
+        // stand in for it leaves the root offering no candidate at all.
+        dep.normalized_bare_specifier = None;
+        if let Some(identity) = local_target_identity(&spec, project_dir)? {
+            if let Some(name) = identity.name {
+                dep.pkg_name = name;
+            }
+            dep.normalized_bare_specifier = Some(identity.version);
+        }
Relevance

⭐ Low

Analogous “don’t treat absolute file: as project-relative” change was explicitly rejected in #13384.

PR-#13384

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The workspace-root dep rewrite unconditionally clears the original specifier and then overwrites it
with the local target’s manifest.version; local_target_identity() builds the read path with
project_dir.join(path_without_protocol), which on absolute paths ignores project_dir and still
succeeds in reading an absolute target. Separately, other parts of the codebase treat absolute/drive
paths as a distinct class of local selector, supporting that absolute-path handling should not be
lumped into “project-relative”.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-876]
pnpm/crates/cli/src/cli_args/global.rs[593-626]
pnpm/crates/package-manager/src/optimistic_repeat_install.rs[545-596]
PR-#13006

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 root-dep pinning logic clears `normalized_bare_specifier` and substitutes `manifest.version` for any dep deemed “project-relative”. Because the predicate includes all `file:` / `link:` specs, absolute-path targets (e.g. `file:/opt/pkg`, `link:C:\\pkg`, `file:\\server\\share\\pkg`, or drive-relative `c:dir`) can be rewritten into a plain semver version. That makes the *peer-hoist candidate* registry-shaped (`"1.2.3"`) even though the original root dep was an importer-independent absolute path.

### Issue Context
Absolute `file:`/`link:` selectors are not directory-relative to the importer, so they *can* be hoisted verbatim safely. Rewriting them to a version changes resolution semantics for hoisted peers (may fetch remote code, or fail if the version is not published).

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[860-874]

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


4. Missing trailing commas in params 📘 Rule violation ⚙ Maintainability
Description
Multi-line TypeScript function parameter lists were added without trailing commas, which violates
the repository’s trailing-comma requirement and increases diff churn on future edits.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R523-526]

+async function getHoistableRootDeps (
  rootImporter: ImporterToResolve | undefined,
  rootPkgAddresses: PkgAddressOrLink[]
-): HoistableRootDep[] {
+): Promise<HoistableRootDep[]> {
Relevance

⭐ Low

Trailing-comma enforcement is often rejected in this repo; multiple PRs declined adding missing
trailing commas.

PR-#13289
PR-#13288
PR-#13133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs. In the updated
file, getHoistableRootDeps and pinProjectRelativeDepToItsVersion have multi-line parameter lists
where the last parameter line lacks a trailing comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-526]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[578-581]

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

## Issue description
New multi-line TypeScript function signatures are missing trailing commas on the last parameter.

## Issue Context
The repo requires trailing commas in TypeScript multi-line constructs to keep diffs stable.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-526]
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[578-581]

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


Grey Divider

Previous review results

Review updated until commit 6bf0733

Results up to commit 6cdfe8c ⚖️ Balanced


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


Remediation recommended
1. Blocking manifest reads 🐞 Bug ➹ Performance
Description
The resolver now reads workspace-root local dependency manifests via synchronous filesystem I/O
during dependency resolution, which can block async executor threads and slow installs on large
workspaces or slow filesystems. This work is triggered specifically for root
link:/file:/workspace:. deps when building the hoistable root-dep candidate list.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R791-803]

+/// [`safe_read_package_json_from_dir`] maps only a missing file to
+/// `Ok(None)`; a `file:` target is a tarball as often as a directory, and
+/// a path component of a tarball is not a directory to read a manifest
+/// from.
+fn read_manifest_of_local_target(
+    dir: &Path,
+) -> Result<Option<serde_json::Value>, PackageManifestError> {
+    match safe_read_package_json_from_dir(dir) {
+        Err(PackageManifestError::Io(err)) if err.kind() == io::ErrorKind::NotADirectory => {
+            Ok(None)
+        }
+        result => result,
+    }
Relevance

⭐⭐ Medium

Team accepts hot-path perf improvements, but no clear precedent on replacing sync manifest reads
with nonblocking IO.

PR-#13172
PR-#13359

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new pinning path reads local targets’ manifests, and the underlying helper performs synchronous
fs::read_to_string, so this adds blocking disk I/O to the resolver’s install-time flow.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-804]
pnpm/crates/package-manifest/src/lib.rs[837-850]

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

## Issue description
`read_manifest_of_local_target()` calls `safe_read_package_json_from_dir()`, which uses `std::fs::read_to_string`. This synchronous disk I/O now happens on the dependency-resolution hot path when pinning project-relative root deps, potentially blocking Tokio worker threads.

## Issue Context
This path is reached from `build_workspace_root_deps()` when a workspace root dep’s specifier is `link:`/`file:`/`workspace:.` and the code tries to pin it to the linked package’s version.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[760-803]
- pnpm/crates/package-manifest/src/lib.rs[837-850]

## Suggested fix
- Either:
 - Introduce an async variant of `safe_read_package_json_from_dir` (using `tokio::fs`) and make the pinning path async; or
 - Wrap the manifest read/parse in `tokio::task::spawn_blocking` (or equivalent) so the synchronous read doesn’t block executor threads.
- Consider short-circuiting when the version is already known safely (only if you can prove it’s not a synthetic placeholder).

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


2. Unbounded manifest read fanout 🐞 Bug ➹ Performance
Description
getHoistableRootDeps() now runs Promise.all() across all root deps and for each project-relative
dep may read package.json; in large workspaces this can create excessive concurrent file reads and
cause IO contention or EMFILE-style failures. This affects the install hot path when
resolvePeersFromWorkspaceRoot is enabled.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R548-553]

+  return Promise.all(rootDeps.map(async (rootDep) => {
+    if (rootDep.normalizedBareSpecifier == null || !isProjectRelativeSpecifier(rootDep.normalizedBareSpecifier)) {
+      return rootDep
+    }
+    return pinProjectRelativeDepToItsVersion(rootDep, rootDir)
+  }))
Relevance

⭐⭐ Medium

Concurrency limiting is plausible, but repo has accepted Promise.all fanout patterns; unclear if
they’ll cap manifest reads.

PR-#12491
PR-#12855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new implementation explicitly wraps the per-dep pinning (which reads package.json) in a
Promise.all, causing all qualifying manifest reads to start concurrently.

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-605]
pnpm11/pkg-manifest/reader/src/index.ts[39-50]

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

## Issue description
`getHoistableRootDeps()` uses `Promise.all(rootDeps.map(...))` and each project-relative dep can trigger a manifest read from disk. This creates unbounded concurrency proportional to the number of root deps.

## Issue Context
The fan-out only happens when `resolvePeersFromWorkspaceRoot` is enabled and only for root deps whose specifier is `link:`/`file:`/`workspace:.`, but in large workspaces the root can still have many such deps.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-604]

## Suggested fix
- Use a concurrency limiter (the repo already uses `p-limit` elsewhere) to bound simultaneous `safeReadPackageJsonFromDir()` calls (e.g. 8–16).
- Optionally dedupe reads by resolved directory path to avoid reading the same manifest multiple times if aliases point to the same target.

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



Informational
3. Missing trailing commas in params 📘 Rule violation ⚙ Maintainability
Description
Multi-line TypeScript function parameter lists were added without trailing commas, which violates
the repository’s trailing-comma requirement and increases diff churn on future edits.
Code

pnpm11/installing/deps-resolver/src/resolveDependencies.ts[R523-526]

+async function getHoistableRootDeps (
  rootImporter: ImporterToResolve | undefined,
  rootPkgAddresses: PkgAddressOrLink[]
-): HoistableRootDep[] {
+): Promise<HoistableRootDep[]> {
Relevance

⭐ Low

Trailing-comma enforcement is often rejected in this repo; multiple PRs declined adding missing
trailing commas.

PR-#13289
PR-#13288
PR-#13133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs. In the updated
file, getHoistableRootDeps and pinProjectRelativeDepToItsVersion have multi-line parameter lists
where the last parameter line lacks a trailing comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-526]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[578-581]

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

## Issue description
New multi-line TypeScript function signatures are missing trailing commas on the last parameter.

## Issue Context
The repo requires trailing commas in TypeScript multi-line constructs to keep diffs stable.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[523-526]
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts[578-581]

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


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 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.2±0.03ms    33.5 MB/sec    1.01     11.3±0.04ms    33.1 MB/sec
packument/parse                1.00     39.1±0.09µs  1695.1 MB/sec    1.00     39.2±0.20µs  1692.8 MB/sec
tarball/download_dependency    1.00      2.3±0.06ms  1863.6 KB/sec    1.01      2.3±0.07ms  1851.6 KB/sec

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.25%. Comparing base (d17710c) to head (137642c).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13387      +/-   ##
==========================================
+ Coverage   87.22%   87.25%   +0.03%     
==========================================
  Files         536      540       +4     
  Lines       92059    92662     +603     
==========================================
+ Hits        80297    80855     +558     
- Misses      11762    11807      +45     

☔ 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 Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 6cdfe8c6c862

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

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.515 ± 0.179 2.342 2.777 1.67 ± 0.20
pacquet@main 2.604 ± 0.153 2.342 2.774 1.73 ± 0.19
pnpr@HEAD 1.506 ± 0.143 1.367 1.815 1.00
pnpr@main 1.568 ± 0.155 1.352 1.731 1.04 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5146719885400004,
      "stddev": 0.17890334507587285,
      "median": 2.4364579710400003,
      "user": 1.4696495799999998,
      "system": 1.30663662,
      "min": 2.3424648970399997,
      "max": 2.7773003740399997,
      "times": [
        2.36035291604,
        2.34760931504,
        2.48793291604,
        2.38498302604,
        2.63329188904,
        2.76716641704,
        2.3424648970399997,
        2.7773003740399997,
        2.66809095104,
        2.37752718404
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.6041054462399997,
      "stddev": 0.15313681951444919,
      "median": 2.65192052604,
      "user": 1.4789612799999998,
      "system": 1.30441532,
      "min": 2.3423185210399997,
      "max": 2.77369026904,
      "times": [
        2.77369026904,
        2.41587027604,
        2.71737058004,
        2.5569018190399997,
        2.59433766604,
        2.74195190904,
        2.3423185210399997,
        2.46631947904,
        2.70950338604,
        2.72279055704
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.50562875194,
      "stddev": 0.14309034749575078,
      "median": 1.4819925405399998,
      "user": 1.01217948,
      "system": 1.18021272,
      "min": 1.36668426704,
      "max": 1.81465874504,
      "times": [
        1.49769764804,
        1.36668426704,
        1.3704740070399999,
        1.54007741904,
        1.65388064104,
        1.46628743304,
        1.54990211504,
        1.37155344504,
        1.81465874504,
        1.42507179904
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5683603545400002,
      "stddev": 0.1554448851391461,
      "median": 1.58863341704,
      "user": 1.0457895799999999,
      "system": 1.15722292,
      "min": 1.3522055390399998,
      "max": 1.73118014904,
      "times": [
        1.69033020204,
        1.53019710904,
        1.3522055390399998,
        1.73118014904,
        1.39065354504,
        1.36063247904,
        1.5504687290399999,
        1.72368942904,
        1.72744825904,
        1.62679810504
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 252.0 ± 6.7 239.7 259.7 1.00
pacquet@main 258.9 ± 7.7 247.7 271.2 1.03 ± 0.04
pnpr@HEAD 273.0 ± 5.7 261.8 284.0 1.08 ± 0.04
pnpr@main 270.6 ± 11.3 254.7 287.0 1.07 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25198526246,
      "stddev": 0.006685150490839992,
      "median": 0.25503159596,
      "user": 0.21486171999999995,
      "system": 0.5027994599999999,
      "min": 0.23969130796000002,
      "max": 0.25970951096,
      "times": [
        0.24527569896,
        0.25680179996,
        0.23969130796000002,
        0.24763991496,
        0.25787569396,
        0.25428735296,
        0.24643484696,
        0.25636065896,
        0.25577583896,
        0.25970951096
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25894595536000004,
      "stddev": 0.0076853400776414095,
      "median": 0.25984461546000004,
      "user": 0.21525381999999998,
      "system": 0.5171389599999999,
      "min": 0.24769230896,
      "max": 0.27119048496000003,
      "times": [
        0.26448192896,
        0.24769230896,
        0.25381384296,
        0.26350290996000003,
        0.26573099596,
        0.25153175396,
        0.27119048496000003,
        0.25182609696,
        0.26330444696,
        0.25638478396000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27299491176,
      "stddev": 0.005654150504433411,
      "median": 0.27385423546,
      "user": 0.22334932000000002,
      "system": 0.53742166,
      "min": 0.26184768996,
      "max": 0.28404283696,
      "times": [
        0.27379053096,
        0.26895175796,
        0.27477206496,
        0.28404283696,
        0.27579395496000003,
        0.26184768996,
        0.26962506296,
        0.27409637496,
        0.27311090396,
        0.27391793996
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27060628626,
      "stddev": 0.011285210165614665,
      "median": 0.26925948146,
      "user": 0.23996051999999998,
      "system": 0.49149626,
      "min": 0.25467360796,
      "max": 0.28703846596,
      "times": [
        0.26406995496,
        0.26468681396,
        0.25942135796,
        0.25467360796,
        0.26186536296,
        0.27530583796,
        0.27914865896,
        0.27383214896,
        0.28602065296,
        0.28703846596
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.762 ± 0.015 2.736 2.783 1.80 ± 0.13
pacquet@main 2.766 ± 0.020 2.721 2.793 1.80 ± 0.13
pnpr@HEAD 1.614 ± 0.121 1.456 1.844 1.05 ± 0.11
pnpr@main 1.536 ± 0.113 1.442 1.824 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.76203982616,
      "stddev": 0.014761340948039721,
      "median": 2.7640169096600005,
      "user": 1.69384258,
      "system": 1.30798778,
      "min": 2.73591124116,
      "max": 2.7827307301600004,
      "times": [
        2.73591124116,
        2.7694591511600004,
        2.7532272001600004,
        2.76700191416,
        2.7797798351600003,
        2.7827307301600004,
        2.7610319051600003,
        2.77125791116,
        2.7489323631600002,
        2.75106601016
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.76551560646,
      "stddev": 0.020278234726145573,
      "median": 2.76794975466,
      "user": 1.7225677799999999,
      "system": 1.2704357799999997,
      "min": 2.7214200031600004,
      "max": 2.7930954911600003,
      "times": [
        2.7501810581600004,
        2.7690559881600003,
        2.7677934961600004,
        2.7214200031600004,
        2.76810601316,
        2.7593306071600003,
        2.75901670616,
        2.78484166416,
        2.7930954911600003,
        2.78231503716
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6135359185600002,
      "stddev": 0.12118649496543672,
      "median": 1.5806567606600002,
      "user": 1.00837238,
      "system": 1.1756284799999999,
      "min": 1.45563726116,
      "max": 1.8437581631600002,
      "times": [
        1.8437581631600002,
        1.77524050916,
        1.51301213116,
        1.5859664611600002,
        1.45563726116,
        1.66209688716,
        1.65102869316,
        1.5753470601600001,
        1.54607775216,
        1.52719426716
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.53552590426,
      "stddev": 0.11323094451024514,
      "median": 1.50460289366,
      "user": 1.0504278799999998,
      "system": 1.14378528,
      "min": 1.44245535716,
      "max": 1.8238380391600002,
      "times": [
        1.44245535716,
        1.45738061716,
        1.52336326816,
        1.48434428416,
        1.50729476016,
        1.58477225716,
        1.8238380391600002,
        1.58398635016,
        1.50191102716,
        1.44591308216
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 589.6 ± 9.2 580.9 608.2 1.92 ± 0.07
pacquet@main 592.9 ± 9.7 573.6 606.8 1.94 ± 0.07
pnpr@HEAD 306.5 ± 5.8 295.9 313.4 1.00 ± 0.04
pnpr@main 306.3 ± 9.3 292.3 319.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5895763278399999,
      "stddev": 0.00922232692553926,
      "median": 0.58441086044,
      "user": 0.7171172599999999,
      "system": 0.6644636599999998,
      "min": 0.58093309194,
      "max": 0.60815665594,
      "times": [
        0.58270094394,
        0.58093309194,
        0.60815665594,
        0.58460997894,
        0.58409637494,
        0.60162188894,
        0.58421174194,
        0.58343746794,
        0.59092481294,
        0.59507032094
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.59288383254,
      "stddev": 0.009669806743820458,
      "median": 0.59435912494,
      "user": 0.69346396,
      "system": 0.7031755599999998,
      "min": 0.57361426294,
      "max": 0.60680303294,
      "times": [
        0.57361426294,
        0.58807362694,
        0.58463799194,
        0.59865092794,
        0.60680303294,
        0.59685120594,
        0.60296521294,
        0.58852381394,
        0.59197609794,
        0.59674215194
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30648158034,
      "stddev": 0.005841396985712474,
      "median": 0.30591929444000004,
      "user": 0.19770406000000001,
      "system": 0.5470994599999999,
      "min": 0.29590720394000003,
      "max": 0.31342758894000006,
      "times": [
        0.31342758894000006,
        0.30395906194000005,
        0.30340285694,
        0.30346529394000005,
        0.30952866494000003,
        0.31337859794000006,
        0.29590720394000003,
        0.30787952694000004,
        0.31254050294,
        0.30132650494
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30633498004000004,
      "stddev": 0.009271140426703215,
      "median": 0.30438334844000003,
      "user": 0.20006165999999997,
      "system": 0.52559706,
      "min": 0.29229495794000004,
      "max": 0.31926309194,
      "times": [
        0.31738764894000004,
        0.29229495794000004,
        0.30362900194000003,
        0.31926309194,
        0.29975264094000004,
        0.30234379694,
        0.31657425294,
        0.29648164794000004,
        0.30513769494000004,
        0.31048506594
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.913 ± 0.011 1.898 1.932 6.32 ± 0.11
pacquet@main 1.902 ± 0.008 1.889 1.913 6.28 ± 0.11
pnpr@HEAD 0.303 ± 0.005 0.295 0.312 1.00
pnpr@main 0.304 ± 0.005 0.294 0.313 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9127387598600003,
      "stddev": 0.010989967049315192,
      "median": 1.91123570736,
      "user": 0.92884066,
      "system": 0.78661428,
      "min": 1.8982907253599999,
      "max": 1.9318201253599998,
      "times": [
        1.9318201253599998,
        1.92697200036,
        1.9181441713599998,
        1.91618788736,
        1.9079070653599999,
        1.8982907253599999,
        1.91332567236,
        1.8985428393600001,
        1.90705136936,
        1.90914574236
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.9020357064599995,
      "stddev": 0.007815970661460338,
      "median": 1.90162041986,
      "user": 0.94065136,
      "system": 0.7447369799999999,
      "min": 1.8886662913599999,
      "max": 1.9128081103599999,
      "times": [
        1.90744077036,
        1.8994724563599998,
        1.9120915643599998,
        1.90312156936,
        1.8919759963599998,
        1.9001192703599998,
        1.89989228436,
        1.9128081103599999,
        1.8886662913599999,
        1.90476875136
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3027396552600001,
      "stddev": 0.005044520528005847,
      "median": 0.30167035336000003,
      "user": 0.19600416,
      "system": 0.5467913799999999,
      "min": 0.29487118336,
      "max": 0.31217473036000004,
      "times": [
        0.30847849936000005,
        0.30015908536,
        0.29487118336,
        0.30231984336,
        0.29880135436000005,
        0.30302662036000005,
        0.31217473036000004,
        0.30102086336000006,
        0.30637116136000003,
        0.30017321136
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30360850786000004,
      "stddev": 0.005215182883868056,
      "median": 0.30301560936000005,
      "user": 0.20162535999999998,
      "system": 0.53266678,
      "min": 0.29426705936,
      "max": 0.31305432336000005,
      "times": [
        0.30566951336000003,
        0.31305432336000005,
        0.30293923636000003,
        0.30968555536000003,
        0.30269185136000004,
        0.30449602936000003,
        0.30029894736,
        0.29426705936,
        0.29989058036000005,
        0.30309198236
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 353.9 ± 8.6 346.8 375.7 4.05 ± 0.13
pacquet@main 357.6 ± 11.5 344.9 376.6 4.10 ± 0.15
pnpr@HEAD 87.3 ± 1.6 84.7 90.5 1.00
pnpr@main 87.3 ± 1.2 83.0 89.3 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35385651606000007,
      "stddev": 0.008643050511347054,
      "median": 0.35174555586,
      "user": 0.34901272,
      "system": 0.05105014,
      "min": 0.34683966686,
      "max": 0.37574137586,
      "times": [
        0.37574137586,
        0.34809028586,
        0.34872292386000003,
        0.34683966686,
        0.35508292786,
        0.34737346986,
        0.35442756786,
        0.34906354386000005,
        0.35548926186,
        0.35773413686000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.35760737636,
      "stddev": 0.011466361324338472,
      "median": 0.35243427836,
      "user": 0.35318521999999997,
      "system": 0.05039774,
      "min": 0.34493147386,
      "max": 0.37664924086,
      "times": [
        0.34755890886,
        0.35259400286000003,
        0.35114667586000003,
        0.36200207286,
        0.34975563386,
        0.34493147386,
        0.36265018886,
        0.37664924086,
        0.37651101186,
        0.35227455386
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08727175361757578,
      "stddev": 0.0016489182703031593,
      "median": 0.08714680486000001,
      "user": 0.021649523030303024,
      "system": 0.00781400606060606,
      "min": 0.08474479386000001,
      "max": 0.09051269586,
      "times": [
        0.08595570786000001,
        0.08638404186000001,
        0.08578538786,
        0.08789874586000002,
        0.08822694386,
        0.08952664386,
        0.08474479386000001,
        0.09051269586,
        0.08511130186,
        0.08796766586,
        0.08585840386000002,
        0.08747909786000001,
        0.08993384786000001,
        0.08690289686000001,
        0.08494472886000001,
        0.09005600686000001,
        0.08502553086,
        0.08773555986,
        0.08651409686000001,
        0.08685912486000001,
        0.08804045186000001,
        0.08740264486,
        0.08653689886,
        0.08978191386,
        0.08536811386000001,
        0.08740264586,
        0.08700512786,
        0.08931294186000001,
        0.08657782586000001,
        0.08958026486000001,
        0.08521082886,
        0.08714680486000001,
        0.08717818286000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.087284922735,
      "stddev": 0.0011700973049192968,
      "median": 0.08732617586000001,
      "user": 0.021631657500000005,
      "system": 0.00767156875,
      "min": 0.08295401086000001,
      "max": 0.08926836886,
      "times": [
        0.08740298486,
        0.08739584186,
        0.08722520086,
        0.08295401086000001,
        0.08744679786000001,
        0.08725650986000001,
        0.08782390586000001,
        0.08697903886000001,
        0.08673357886000001,
        0.08818314986,
        0.08705136486000001,
        0.08746460186,
        0.08860922986000001,
        0.08644851286,
        0.08723512086000001,
        0.08839194286,
        0.08682090286000001,
        0.08659390586000001,
        0.08823632986,
        0.08686559586,
        0.08765485886,
        0.08818431386000002,
        0.08672107486000001,
        0.08713891986000001,
        0.08760447286,
        0.08682458886000001,
        0.08799648986000001,
        0.08822617086000001,
        0.08630547486000001,
        0.08926836886,
        0.08496529786000001,
        0.08910896886000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.580 ± 0.143 4.438 4.847 1.32 ± 0.04
pacquet@main 4.547 ± 0.152 4.400 4.871 1.31 ± 0.04
pnpr@HEAD 3.478 ± 0.027 3.444 3.533 1.00
pnpr@main 3.551 ± 0.127 3.451 3.837 1.02 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.57961458542,
      "stddev": 0.1431512577233899,
      "median": 4.53271856172,
      "user": 1.7261493600000002,
      "system": 1.3026516799999999,
      "min": 4.43750216522,
      "max": 4.84677481822,
      "times": [
        4.64402606422,
        4.53639790522,
        4.43750216522,
        4.84677481822,
        4.46078963122,
        4.54291399522,
        4.81027514022,
        4.52903921822,
        4.5168886192199995,
        4.47153829722
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.546506967919999,
      "stddev": 0.1519484827363178,
      "median": 4.47976392522,
      "user": 1.71202606,
      "system": 1.33317328,
      "min": 4.40007635622,
      "max": 4.87123095022,
      "times": [
        4.55857695222,
        4.69578068222,
        4.47155972722,
        4.48796812322,
        4.43638342322,
        4.87123095022,
        4.40007635622,
        4.43570061022,
        4.66552263422,
        4.44227022022
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.4778334822200003,
      "stddev": 0.026750317808805043,
      "median": 3.47468607822,
      "user": 1.1800492599999999,
      "system": 1.21096488,
      "min": 3.44434912822,
      "max": 3.5334709052199997,
      "times": [
        3.47149250522,
        3.5334709052199997,
        3.47787965122,
        3.45725731022,
        3.45461904622,
        3.44434912822,
        3.49602905722,
        3.46080528322,
        3.50221077022,
        3.48022116522
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5513337819200004,
      "stddev": 0.12653451768351967,
      "median": 3.5083796197200003,
      "user": 1.1776433599999998,
      "system": 1.2343654799999997,
      "min": 3.45138891022,
      "max": 3.83687347322,
      "times": [
        3.50455523222,
        3.83687347322,
        3.48846341322,
        3.45138891022,
        3.5122040072200003,
        3.5544460942200002,
        3.45612049622,
        3.52535908022,
        3.71816460822,
        3.4657625042199998
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13387
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
2,735.91 ms
(+0.02%)Baseline: 2,735.36 ms
3,282.43 ms
(83.35%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,898.29 ms
(+0.42%)Baseline: 1,890.41 ms
2,268.49 ms
(83.68%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
580.93 ms
(+1.16%)Baseline: 574.28 ms
689.14 ms
(84.30%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
346.84 ms
(-0.67%)Baseline: 349.19 ms
419.03 ms
(82.77%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,342.46 ms
(-0.75%)Baseline: 2,360.09 ms
2,832.11 ms
(82.71%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,437.50 ms
(+0.26%)Baseline: 4,425.88 ms
5,311.06 ms
(83.55%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
239.69 ms
(-2.91%)Baseline: 246.88 ms
296.25 ms
(80.91%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13387
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
1,455.64 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
294.87 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
295.91 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.74 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,366.68 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,444.35 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
261.85 ms
🐰 View full continuous benchmarking report in Bencher

…not its path

A workspace-root dependency declared with link:, file:, or the path form
of workspace: names a directory relative to the root, so hoisting the
specifier verbatim re-resolved it against the directory of the importer
the peer was hoisted into: a root `link:ajv-local` reached pkg/ajv-local
and left a dangling symlink there.

Both stacks now substitute the linked package's own version for its path.
The root keeps the authority over the peer that it has when it declares
the package with a version range — a sibling's newer copy no longer wins
over the version the root pins — and the peer resolves to the same
package from every importer. The manifest is read from disk rather than
taken from the resolved dependency, which a linked dep reused from the
lockfile does not have; reading it keeps a repeat install hoisting what a
fresh install of the same manifest hoists. A target with no manifest to
read (a file: tarball, a path that does not exist) or no valid version in
it is not a candidate, and the peer falls through to the ordinary
auto-install path.

A workspace: range needs none of this: it selects the same workspace
package from every importer, so it is hoisted as-is. pacquet previously
dropped it and resolved a second copy off the registry for a peer the
root already provided from the workspace.

The same candidate list bounds optional-peer hoisting, so
getHoistableOptionalPeers picks up the rule with no change of its own.

Closes #13373.
Copilot AI review requested due to automatic review settings July 26, 2026 00:30

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 reached their quota limit.

@zkochan zkochan changed the title fix(resolving-deps-resolver): hoist only root peers whose specifier is importer-independent fix(resolving-deps-resolver): hoist a local root dep by its version, not its path Jul 26, 2026

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
pnpm11/installing/deps-resolver/src/resolveDependencies.ts (1)

578-594: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: pass the specifier in rather than re-asserting it.

The two ! assertions on Line 582 rely on the guard in the caller at Line 549. Taking the already-narrowed specifier as a parameter removes the assertions and makes the invariant type-checked.

♻️ Proposed refactor
 async function pinProjectRelativeDepToItsVersion (
   rootDep: HoistableRootDep,
+  bareSpecifier: string,
   rootDir: string | undefined
 ): Promise<HoistableRootDep> {
-  const pathWithoutProtocol = rootDep.normalizedBareSpecifier!.slice(rootDep.normalizedBareSpecifier!.indexOf(':') + 1)
+  const pathWithoutProtocol = bareSpecifier.slice(bareSpecifier.indexOf(':') + 1)

and at the call site:

-  return pinProjectRelativeDepToItsVersion(rootDep, rootDir)
+  return pinProjectRelativeDepToItsVersion(rootDep, rootDep.normalizedBareSpecifier, rootDir)
🤖 Prompt for 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.

In `@pnpm11/installing/deps-resolver/src/resolveDependencies.ts` around lines 578
- 594, Update pinProjectRelativeDepToItsVersion to accept the already-narrowed
normalized bare specifier as a parameter, and use that parameter when removing
the protocol instead of re-reading rootDep.normalizedBareSpecifier with non-null
assertions. Update its caller to pass the guarded specifier while preserving the
existing manifest resolution and return behavior.
🤖 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.

Nitpick comments:
In `@pnpm11/installing/deps-resolver/src/resolveDependencies.ts`:
- Around line 578-594: Update pinProjectRelativeDepToItsVersion to accept the
already-narrowed normalized bare specifier as a parameter, and use that
parameter when removing the protocol instead of re-reading
rootDep.normalizedBareSpecifier with non-null assertions. Update its caller to
pass the guarded specifier while preserving the existing manifest resolution and
return behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d7825ade-84ef-40be-a31e-07fd5e1e4845

📥 Commits

Reviewing files that changed from the base of the PR and between 137642c and 6cdfe8c.

📒 Files selected for processing (8)
  • .changeset/peer-hoist-skips-project-relative-root-deps.md
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm11/installing/deps-installer/test/install/peerDependencies.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6cdfe8c

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

@blacksmith-sh

blacksmith-sh Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
test/install/bunRuntime.ts/bunRuntime View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…mes no version

Both stacks already dropped the candidate in that case — a path must never
survive as the hoisted specifier — but only the no-manifest-at-all shape
was covered, and pacquet expressed the drop by taking the specifier out of
the dep before reading the target, which reads as if the early returns
left the path in place. The drop is now written where it happens, and each
stack has a test for a target whose manifest carries no version.
Copilot AI review requested due to automatic review settings July 26, 2026 00:57

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 reached their quota limit.

Copilot AI review requested due to automatic review settings July 26, 2026 00:57

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 reached their quota limit.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6bf0733

@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 merged commit f892e3d into main Jul 26, 2026
30 of 33 checks passed
@zkochan
zkochan deleted the fix-13373 branch July 26, 2026 01:06

@coderabbitai coderabbitai 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.

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 `@pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs`:
- Around line 768-787: The local_target_identity function must treat
tarball-style file targets and paths without a usable package.json as ineligible
root peer candidates rather than propagating Io or Parse errors. Update its
manifest-loading flow to convert those non-directory/package-root failures into
Ok(None), while preserving successful manifest identity extraction and
propagation of unrelated errors.
🪄 Autofix (Beta)

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: 1d04b8c0-165a-436b-b82b-2b6304b21397

📥 Commits

Reviewing files that changed from the base of the PR and between 6cdfe8c and 6bf0733.

📒 Files selected for processing (3)
  • pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm11/installing/deps-installer/test/install/peerDependencies.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs

Comment on lines +768 to +787
fn local_target_identity(
spec: &str,
project_dir: &Path,
) -> Result<Option<LocalTargetIdentity>, PackageManifestError> {
let path_without_protocol = spec.split_once(':').map_or(spec, |(_, path)| path);
let Some(manifest) = read_manifest_of_local_target(&project_dir.join(path_without_protocol))?
else {
return Ok(None);
};
let Some(version) = manifest.get("version").and_then(serde_json::Value::as_str) else {
return Ok(None);
};
if version.parse::<Version>().is_err() {
return Ok(None);
}
Ok(Some(LocalTargetIdentity {
name: manifest.get("name").and_then(serde_json::Value::as_str).map(str::to_string),
version: version.to_string(),
}))
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
ast-grep run --pattern 'fn read_manifest_of_local_target($$$) { $$$ }' --lang rust pnpm/crates/resolving-deps-resolver/src

Repository: pnpm/pnpm

Length of output: 147


🏁 Script executed:

#!/bin/bash
set -u
echo "== candidate files =="
git ls-files 'pnpm/crates/resolving-deps-resolver/src/*'
echo
echo "== resolve_importer relevant symbols/uses =="
rg -n "read_manifest_of_local_target|local_target_identity|LocalTargetIdentity|fn .*read_manifest" pnpm/crates/resolving-deps-resolver/src || true
echo
echo "== resolve_importer outline =="
ast-grep outline pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs --view compact || true
echo
echo "== relevant lines around local_target_identity =="
sed -n '720,810p' pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs

Repository: pnpm/pnpm

Length of output: 6608


🏁 Script executed:

#!/bin/bash
set -u
echo "== imports =="
sed -n '1,80p' pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs || true
echo
echo "== safe_read_package_json_from_dir definition =="
rg -n "fn safe_read_package_json_from_dir|read_package_json|package.json" pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs pnpm/crates -g '*.rs' | head -80 || true
echo
echo "== local_target_identity callsites =="
rg -n "local_target_identity\\(" pnpm/crates/resolving-deps-tracker pnpm/crates/resolving-deps-resolver -g '*.rs' || true
sed -n '830,900p' pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs || true

Repository: pnpm/pnpm

Length of output: 15266


🏁 Script executed:

#!/bin/bash
set -u
echo "== package manifest helper candidates =="
git ls-files | rg 'package-manifest|package_manifest|package manifest' | head -50
echo
echo "== definitions/usages =="
rg -n "safe_read_package_json_from_dir|read_package_json|PackageManifestError" pnpm/crates -g '*.rs' | head -120 || true
echo
echo "== tarball target handling in local resolver =="
sed -n '220,315p' pnpm/crates/resolving-local-resolver/src/local_resolver.rs || true

Repository: pnpm/pnpm

Length of output: 19131


🏁 Script executed:

#!/bin/bash
set -u
echo "== package manifest safe read implementation =="
sed -n '825,870p' pnpm/crates/package-manifest/src/lib.rs || true
echo
echo "== package manifest error enum =="
sed -n '1,90p' pnpm/crates/package-manifest/src/lib.rs || true
echo
echo "== tests around safe_read_package_json_from_dir error handling =="
sed -n '900,940p' pnpm/crates/package-manifest/src/tests.rs || true

Repository: pnpm/pnpm

Length of output: 7230


Handle tarball-style local deps in root peer pinning.

safe_read_package_json_from_dir only returns Ok(None) for a missing package.json; a file: target that names a tarball archive or a path with no package.json propogates an Io/Parse error through local_target_identity, breaking the workspace root resolve instead of treating the target as ineligible. Match pnpm/local resolver behavior: if the target is not a directory/package root, exclude it from root peer candidates rather than failing the whole resolution.

🤖 Prompt for 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.

In `@pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs` around lines 768
- 787, The local_target_identity function must treat tarball-style file targets
and paths without a usable package.json as ineligible root peer candidates
rather than propagating Io or Parse errors. Update its manifest-loading flow to
convert those non-directory/package-root failures into Ok(None), while
preserving successful manifest identity extraction and propagation of unrelated
errors.

kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…not its path (pnpm#13387)

A workspace-root dependency declared with link:, file:, or the path form
of workspace: names a directory relative to the root, so hoisting the
specifier verbatim re-resolved it against the directory of the importer
the peer was hoisted into: a root `link:ajv-local` reached pkg/ajv-local
and left a dangling symlink there.

Both stacks now substitute the linked package's own version for its path.
The root keeps the authority over the peer that it has when it declares
the package with a version range — a sibling's newer copy no longer wins
over the version the root pins — and the peer resolves to the same
package from every importer. The manifest is read from disk rather than
taken from the resolved dependency, which a linked dep reused from the
lockfile does not have; reading it keeps a repeat install hoisting what a
fresh install of the same manifest hoists. A target with no manifest to
read (a file: tarball, a path that does not exist) or no valid version in
it is not a candidate, and the peer falls through to the ordinary
auto-install path.

A workspace: range needs none of this: it selects the same workspace
package from every importer, so it is hoisted as-is. pacquet previously
dropped it and resolved a second copy off the registry for a peer the
root already provided from the workspace.

The same candidate list bounds optional-peer hoisting, so
getHoistableOptionalPeers picks up the rule with no change of its own.

Closes pnpm#13373.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Peer hoisting: the two stacks disagree on which workspace-root specifiers may satisfy a peer

3 participants