Skip to content

fix(global): skip absent package directories when scanning bin ownership - #15381

Merged
zkochan merged 3 commits into
mainfrom
fix-self-install
Sep 23, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-self-install

Conversation

@zkochan

@zkochan zkochan commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

pnpm add -g, pnpm update -g, and pnpm remove -g scan every other global group's bin ownership before mutating anything. That scan failed closed on any dependency manifest it could not read, so a group whose package directory is a link into a global virtual store that no longer holds the package aborted the whole command:

Error: ERR_PNPM_PACKAGE_MANIFEST_IO_ERROR
  × scan existing global installs
  ╰─▶ Failed to read .../global/v11/59f0-19e5f101aa4/node_modules/codemod/package.json: No such file or directory (os error 2)

The pnpm install script (curl -fsSL https://get.pnpm.io/install.sh | sh -) runs pnpm add -g for @pnpm/exe, so on a machine whose store had been pruned pnpm could not be updated at all.

A dependency whose directory under node_modules is absent is definitively not installed, the same way a group without node_modules is (#15151): no bin can resolve through a directory that is not there. Such a dependency now reads as owning no bins. A directory that exists but lacks a readable, valid manifest still fails closed, and every non-ENOENT probe error still surfaces, so the preflight property from #13985 is kept.

The bug is in both stacks, so both are fixed: the Rust pnpm-global crate and the TypeScript @pnpm/global.packages package.

Verification:

  • Reproduced the exact error with the released pnpm 12.6.0 binary against copies of the dangling groups from the affected machine, in a sandbox PNPM_HOME. The patched binary completes the same add -g.
  • Rust: pnpm-global unit tests (18) and the pnpm-cli global ownership e2e tests (18), including the new absent-directory and dangling-link cases.
  • TypeScript: @pnpm/global.commands getInstalledBinNames and globalRemove suites (14).

Squash Commit Body

Enumerating a global group's bins failed closed on every declared dependency
whose manifest could not be read. A group whose package directory is a link
into the global virtual store that no longer holds the package therefore
aborted every `pnpm add -g`, `pnpm update -g`, and `pnpm remove -g` that had
to scan the other groups, with ERR_PNPM_PACKAGE_MANIFEST_IO_ERROR naming the
dangling manifest path. The pnpm install script hit this while replacing the
existing pnpm CLI group on a machine whose store had been pruned, so pnpm
could not be updated at all.

A dependency whose directory under `node_modules` is absent is definitively
not installed, the same way a group without `node_modules` is: no bin can
resolve through a directory that is not there. Such a dependency now reads
as owning no bins. A directory that exists but lacks a readable, valid
manifest still fails closed, so unknown ownership is never treated as
unowned, and every non-ENOENT probe error still surfaces.

Both stacks probe the dependency directory before reading its manifest. The
Rust probe goes through the FsReadDir capability so the fake-filesystem unit
tests keep exercising the per-manifest error paths.

The unit test that models one missing manifest now creates the dependency
directory first, since an absent directory is the case being relaxed. New
unit and e2e tests cover an absent directory and a dangling link in each
stack.

Checklist

  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added a changeset (pnpm, pacquet, @pnpm/global.packages).
  • Added or updated tests.

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

Summary by CodeRabbit

  • Bug Fixes
    • Global package add, update, and remove operations no longer fail when another installed package has a missing directory or a dangling link to its store files.
    • Packages with unavailable directories no longer claim command shims. Removing a package can remove its shim even if another package’s link is dangling, while preserving the other package’s installation files and markers.

Enumerating a global group's bins failed closed on every declared dependency
whose manifest could not be read. A group whose package directory is a link
into the global virtual store that no longer holds the package therefore
aborted every `pnpm add -g`, `pnpm update -g`, and `pnpm remove -g` that had
to scan the other groups, with ERR_PNPM_PACKAGE_MANIFEST_IO_ERROR naming the
dangling manifest path. The pnpm install script hit this while replacing the
existing pnpm CLI group on a machine whose store had been pruned, so pnpm
could not be updated at all.

A dependency whose directory under `node_modules` is absent is definitively
not installed, the same way a group without `node_modules` is: no bin can
resolve through a directory that is not there. Such a dependency now reads
as owning no bins. A directory that exists but lacks a readable, valid
manifest still fails closed, so unknown ownership is never treated as
unowned, and every non-ENOENT probe error still surfaces.

Both stacks probe the dependency directory before reading its manifest. The
Rust probe goes through the FsReadDir capability so the fake-filesystem unit
tests keep exercising the per-manifest error paths.

The unit test that models one missing manifest now creates the dependency
directory first, since an absent directory is the case being relaxed. New
unit and e2e tests cover an absent directory and a dangling link in each
stack.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 38ceefd5-867f-464c-8455-bfd35d2b8be0

📥 Commits

Reviewing files that changed from the base of the PR and between cd6757d and 0f5a305.

📒 Files selected for processing (4)
  • .changeset/global-scan-skips-absent-package-dirs.md
  • pnpm/crates/global/src/scan.rs
  • pnpm/crates/global/src/scan/tests.rs
  • pnpm11/global/packages/src/scanGlobalPackages.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/global-scan-skips-absent-package-dirs.md

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Rust and TypeScript scanners now skip absent dependency directories when collecting global bins. Tests cover missing manifests and global add or remove when a surviving package link dangles. A changeset marks three packages for patch releases.

Changes

Global package bin ownership

Layer / File(s) Summary
Skip absent directories during bin scans
pnpm/crates/global/src/scan.rs, pnpm/crates/global/src/scan/tests.rs, pnpm/crates/cli/src/cli_args/global/tests.rs, pnpm11/global/packages/src/scanGlobalPackages.ts, pnpm11/global/commands/test/getInstalledBinNames.test.ts, .changeset/global-scan-skips-absent-package-dirs.md
The Rust and TypeScript scanners read each dependency manifest before checking whether its directory is absent. They skip a dependency only when the read fails with ENOENT and a follow-up check confirms the directory is absent. Other read errors remain errors. Tests cover absent directories, dangling links, and missing manifests. The changeset records patch releases for three packages.
Global add and remove with dangling survivor links
pnpm/crates/cli/tests/suite/global/ownership.rs, pnpm11/global/commands/test/globalRemove.test.ts
Tests verify that global add and remove succeed when a survivor has a dangling package link. They also check the shared bin and installation state.

Estimated code review effort: 3 (Moderate) | ~20 minutes

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

Suggested reviewers: dextheking1

Merge Risk: ⚪ Minimal · up to 0f5a3

The change appears ready to merge after normal checks; no actionable risk is established for global add or remove with dangling package links.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

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

pnpm11/global/packages/src/scanGlobalPackages.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

@codecov-commenter

codecov-commenter commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.60%. Comparing base (62f9650) to head (0f5a305).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15381      +/-   ##
==========================================
+ Coverage   91.58%   91.60%   +0.02%     
==========================================
  Files        1400     1402       +2     
  Lines      188543   188937     +394     
==========================================
+ Hits       172676   173075     +399     
+ Misses      15867    15862       -5     

☔ 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 Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     12.2±0.70ms    30.8 MB/sec    1.11     13.5±0.65ms    27.7 MB/sec
packument/parse                                  1.02     40.1±1.40µs  1652.8 MB/sec    1.00     39.3±1.21µs  1689.9 MB/sec
tarball/download_dependency                      1.03      4.4±0.44ms   990.3 KB/sec    1.00      4.3±0.40ms  1019.0 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   205.9±23.16ms 77.7 KElem/sec    1.04   214.9±27.14ms 74.5 KElem/sec
workspace_resolution/hoist_heavy                 1.01   292.9±30.57ms        ? ?/sec    1.00   288.8±16.79ms        ? ?/sec
workspace_sort/chained_projects                  1.00     14.1±2.20ms        ? ?/sec    1.02     14.3±2.30ms        ? ?/sec

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2860.62 ms 2748.68 ms -3.9% 143.03 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1460.15 ms 1535.80 ms 5.2% 73.01 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pacquet 269.41 ms 309.83 ms 15.0% 13.47 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pnpr 349.37 ms 279.80 ms -19.9% 17.47 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 10.75 ms 12.24 ms 13.9% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 11.34 ms 10.09 ms -11.0% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 10.09 ms 10.41 ms 3.2% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 9.14 ms 9.11 ms -0.3% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2689.50 ms 2681.45 ms -0.3% 134.47 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1548.41 ms 1652.82 ms 6.7% 77.42 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pacquet 702.77 ms 531.75 ms -24.3% 35.14 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 344.93 ms 360.24 ms 4.4% 17.25 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1653.38 ms 1653.32 ms -0.0% 82.67 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 295.06 ms 299.93 ms 1.7% 14.75 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 257.75 ms 241.02 ms -6.5% 12.89 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 95.59 ms 98.92 ms 3.5% 4.78 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 775.48 ms 710.80 ms -8.3% 38.77 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 218.96 ms 215.50 ms -1.6% 10.95 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4529.20 ms 4734.04 ms 4.5% 226.46 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3571.33 ms 3516.41 ms -1.5% 178.57 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 158.80 ms 142.48 ms -10.3% 7.94 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 262.93 ms 158.10 ms -39.9% 13.15 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 88634a347259

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.808 ± 0.150 2.654 3.073 1.91 ± 0.16
pacquet@main 2.858 ± 0.119 2.653 3.012 1.94 ± 0.15
pnpr@HEAD 1.535 ± 0.107 1.384 1.711 1.04 ± 0.10
pnpr@main 1.472 ± 0.096 1.330 1.630 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.8081086445400008,
      "stddev": 0.1497188929135133,
      "median": 2.7486767752400003,
      "user": 2.3609424799999994,
      "system": 2.11297924,
      "min": 2.6536572032400003,
      "max": 3.0730889182400003
    },
    {
      "command": "pacquet@main",
      "mean": 2.8582785199400003,
      "stddev": 0.11940591148920003,
      "median": 2.86062138724,
      "user": 2.49308248,
      "system": 2.12369494,
      "min": 2.65266215224,
      "max": 3.0117329182400003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5351694098400002,
      "stddev": 0.10700999261639421,
      "median": 1.53580198724,
      "user": 1.5268304799999999,
      "system": 1.5593648400000002,
      "min": 1.3843232082399999,
      "max": 1.71122503824
    },
    {
      "command": "pnpr@main",
      "mean": 1.47169401284,
      "stddev": 0.09594441742825505,
      "median": 1.46014767324,
      "user": 1.29611898,
      "system": 1.42314564,
      "min": 1.32974993524,
      "max": 1.63004306224
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 323.0 ± 60.9 253.8 410.9 1.20 ± 0.25
pacquet@main 268.9 ± 21.8 230.0 294.3 1.00
pnpr@HEAD 278.0 ± 13.1 254.7 295.8 1.03 ± 0.10
pnpr@main 350.8 ± 40.3 284.7 408.6 1.30 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.32302971646,
      "stddev": 0.060919813048736865,
      "median": 0.30982804666,
      "user": 0.35853539999999995,
      "system": 0.7015615199999999,
      "min": 0.25376069466,
      "max": 0.41094230266000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.26890668756,
      "stddev": 0.02183794481305346,
      "median": 0.26940730615999997,
      "user": 0.29668190000000005,
      "system": 0.5971651199999999,
      "min": 0.23003950666,
      "max": 0.29430294966
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27800053826,
      "stddev": 0.01310998646207333,
      "median": 0.27980290066,
      "user": 0.2900723,
      "system": 0.59095292,
      "min": 0.25471266266,
      "max": 0.29580381366
    },
    {
      "command": "pnpr@main",
      "mean": 0.35078405426000003,
      "stddev": 0.04032013160053613,
      "median": 0.34937306766,
      "user": 0.3705615,
      "system": 0.6942343199999998,
      "min": 0.28466877966,
      "max": 0.40855745466000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.8 ± 2.8 7.3 19.9 1.13 ± 0.32
pacquet@main 11.5 ± 2.3 7.2 18.4 1.10 ± 0.27
pnpr@HEAD 10.5 ± 1.6 7.5 18.3 1.00
pnpr@main 11.7 ± 2.2 7.8 22.1 1.12 ± 0.27
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.011848508121717798,
      "stddev": 0.002808032631321737,
      "median": 0.012239813680000001,
      "user": 0.006988886871165643,
      "system": 0.005693479141104293,
      "min": 0.007290826680000001,
      "max": 0.01991933268
    },
    {
      "command": "pacquet@main",
      "mean": 0.0114698315384475,
      "stddev": 0.0022779382353537735,
      "median": 0.01074741868,
      "user": 0.006680170228310505,
      "system": 0.005567982648401828,
      "min": 0.007242495680000001,
      "max": 0.01843813768
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.01046689451181818,
      "stddev": 0.0015547311816927717,
      "median": 0.010090298180000002,
      "user": 0.006153279090909094,
      "system": 0.005058948181818185,
      "min": 0.007481075680000001,
      "max": 0.01831030668
    },
    {
      "command": "pnpr@main",
      "mean": 0.011742767622307696,
      "stddev": 0.002215952967772367,
      "median": 0.01133800218,
      "user": 0.007025200769230772,
      "system": 0.00550388923076923,
      "min": 0.00778103168,
      "max": 0.02212417168
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.5 ± 1.1 8.1 14.2 1.16 ± 0.15
pacquet@main 10.2 ± 1.6 7.1 16.3 1.12 ± 0.20
pnpr@HEAD 9.1 ± 0.7 7.4 11.5 1.00
pnpr@main 9.2 ± 0.9 7.1 12.8 1.01 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.01053797140288288,
      "stddev": 0.0010648741813194945,
      "median": 0.01041250502,
      "user": 0.006006241081081084,
      "system": 0.005278886846846846,
      "min": 0.008147416519999999,
      "max": 0.014164598520000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.010190351680305345,
      "stddev": 0.0016249251851803235,
      "median": 0.01009251702,
      "user": 0.005647908091603057,
      "system": 0.005268318320610683,
      "min": 0.00708133452,
      "max": 0.01628016152
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009111550664680848,
      "stddev": 0.0007425913551583473,
      "median": 0.00911343652,
      "user": 0.005023427404255316,
      "system": 0.004769996765957446,
      "min": 0.00735821852,
      "max": 0.01148558152
    },
    {
      "command": "pnpr@main",
      "mean": 0.009221138015999995,
      "stddev": 0.0009136354010085261,
      "median": 0.00913629652,
      "user": 0.004864520000000001,
      "system": 0.004990934239999998,
      "min": 0.00708370652,
      "max": 0.012773375520000001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.675 ± 0.032 2.624 2.725 1.72 ± 0.13
pacquet@main 2.686 ± 0.046 2.621 2.751 1.72 ± 0.14
pnpr@HEAD 1.655 ± 0.142 1.465 1.818 1.06 ± 0.12
pnpr@main 1.557 ± 0.120 1.412 1.746 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6753769918600003,
      "stddev": 0.03177461659373848,
      "median": 2.6814539167600002,
      "user": 2.42654636,
      "system": 2.0092832600000006,
      "min": 2.6235612497600003,
      "max": 2.72521064476
    },
    {
      "command": "pacquet@main",
      "mean": 2.68568463106,
      "stddev": 0.04575366721503653,
      "median": 2.68949694326,
      "user": 2.4062817599999997,
      "system": 2.02480416,
      "min": 2.62119327576,
      "max": 2.7508579487600002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.65483493956,
      "stddev": 0.14219965797701928,
      "median": 1.65281679276,
      "user": 1.43726366,
      "system": 1.6602689599999998,
      "min": 1.46519213176,
      "max": 1.8183989727600003
    },
    {
      "command": "pnpr@main",
      "mean": 1.5573520435600003,
      "stddev": 0.1200696074749955,
      "median": 1.54840920576,
      "user": 1.28480266,
      "system": 1.5029396599999998,
      "min": 1.4120751667600002,
      "max": 1.7456330107600002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 541.8 ± 39.6 493.9 619.8 1.56 ± 0.16
pacquet@main 670.3 ± 89.7 517.6 767.1 1.93 ± 0.29
pnpr@HEAD 363.4 ± 23.3 335.7 406.9 1.04 ± 0.10
pnpr@main 347.7 ± 23.6 311.2 388.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5418216624800001,
      "stddev": 0.03960721408682463,
      "median": 0.53174773358,
      "user": 0.7948208999999999,
      "system": 0.95544418,
      "min": 0.49386990208000003,
      "max": 0.6198232550800001
    },
    {
      "command": "pacquet@main",
      "mean": 0.6702625392800001,
      "stddev": 0.08971201061797476,
      "median": 0.7027742995800002,
      "user": 1.0184756999999998,
      "system": 1.1114381799999997,
      "min": 0.5175704120800001,
      "max": 0.7670967180800001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.36338319548,
      "stddev": 0.0232593648951956,
      "median": 0.36023557658,
      "user": 0.318597,
      "system": 0.64131328,
      "min": 0.33573899208,
      "max": 0.40686219008
    },
    {
      "command": "pnpr@main",
      "mean": 0.34773722657999995,
      "stddev": 0.023576982480802706,
      "median": 0.34492708758,
      "user": 0.2927202,
      "system": 0.6575983799999999,
      "min": 0.31117310208,
      "max": 0.38884695908
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.661 ± 0.034 1.624 1.720 5.61 ± 0.28
pacquet@main 1.656 ± 0.038 1.600 1.704 5.59 ± 0.29
pnpr@HEAD 0.301 ± 0.008 0.285 0.311 1.02 ± 0.05
pnpr@main 0.296 ± 0.014 0.276 0.315 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.66081757548,
      "stddev": 0.03409940862580703,
      "median": 1.65331849798,
      "user": 0.9594326599999998,
      "system": 1.01386868,
      "min": 1.62387161398,
      "max": 1.72027338198
    },
    {
      "command": "pacquet@main",
      "mean": 1.6561549866800003,
      "stddev": 0.038309190478767734,
      "median": 1.65337581248,
      "user": 0.94226386,
      "system": 0.99205518,
      "min": 1.60011409398,
      "max": 1.70449672498
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30062495798000005,
      "stddev": 0.008296353543815888,
      "median": 0.29993332798000005,
      "user": 0.25621955999999996,
      "system": 0.53572698,
      "min": 0.28470813698,
      "max": 0.31070530198
    },
    {
      "command": "pnpr@main",
      "mean": 0.29605142008,
      "stddev": 0.013564039946813261,
      "median": 0.29506456598,
      "user": 0.23659835999999998,
      "system": 0.54755208,
      "min": 0.27631398298000004,
      "max": 0.31508024998
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 242.2 ± 14.5 219.5 269.2 2.49 ± 0.21
pacquet@main 261.6 ± 25.8 220.3 299.3 2.69 ± 0.31
pnpr@HEAD 99.3 ± 6.6 88.5 114.7 1.02 ± 0.09
pnpr@main 97.2 ± 5.7 89.2 110.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24215506316727273,
      "stddev": 0.014504669650105044,
      "median": 0.24101928044,
      "user": 0.2463179618181818,
      "system": 0.09899526,
      "min": 0.21953056744000002,
      "max": 0.26917740844
    },
    {
      "command": "pacquet@main",
      "mean": 0.26164599034,
      "stddev": 0.025758671627000133,
      "median": 0.25775372143999997,
      "user": 0.2768706799999999,
      "system": 0.09490546000000001,
      "min": 0.22027858144,
      "max": 0.29927938244
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09931484716000001,
      "stddev": 0.0065624155118943405,
      "median": 0.09891924344,
      "user": 0.03857274,
      "system": 0.018414780000000006,
      "min": 0.08845998844,
      "max": 0.11473024344
    },
    {
      "command": "pnpr@main",
      "mean": 0.09722752744,
      "stddev": 0.0057308880382535045,
      "median": 0.09559146544,
      "user": 0.03680858769230769,
      "system": 0.017390259999999998,
      "min": 0.08916649444000001,
      "max": 0.11013210444
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 702.3 ± 134.5 493.4 935.0 1.00
pacquet@main 781.2 ± 108.5 587.2 942.2 1.11 ± 0.26
pnpm@HEAD 3253.9 ± 356.7 2852.4 4002.6 4.63 ± 1.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7023204052511113,
      "stddev": 0.13448207048829888,
      "median": 0.71079965314,
      "user": 0.7259390844444442,
      "system": 0.165706,
      "min": 0.49335661414000004,
      "max": 0.9350285391400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.7811999785844443,
      "stddev": 0.10849441164647314,
      "median": 0.77548327114,
      "user": 0.822784751111111,
      "system": 0.16430977777777775,
      "min": 0.58723071014,
      "max": 0.94224933114
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.253921837251111,
      "stddev": 0.3567241589048285,
      "median": 3.1540358771399997,
      "user": 4.997788306666667,
      "system": 0.25908444444444445,
      "min": 2.85241206814,
      "max": 4.0026082691400005
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 244.3 ± 54.8 194.5 323.7 1.00
pacquet@main 245.7 ± 49.3 195.4 327.6 1.01 ± 0.30
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24425452391384614,
      "stddev": 0.05475752278346776,
      "median": 0.21550188476,
      "user": 0.18075147230769228,
      "system": 0.1214849323076923,
      "min": 0.19446379076,
      "max": 0.32369475176
    },
    {
      "command": "pacquet@main",
      "mean": 0.2457149249138462,
      "stddev": 0.04929778428896532,
      "median": 0.21895989176,
      "user": 0.17394916461538462,
      "system": 0.12898124,
      "min": 0.19540820076,
      "max": 0.32760369976000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.836 ± 0.253 4.545 5.423 1.36 ± 0.09
pacquet@main 4.592 ± 0.171 4.413 4.842 1.29 ± 0.07
pnpr@HEAD 3.561 ± 0.145 3.394 3.805 1.00
pnpr@main 3.589 ± 0.140 3.416 3.901 1.01 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.83607662192,
      "stddev": 0.2532439998161651,
      "median": 4.73403565692,
      "user": 2.4361567400000004,
      "system": 2.08263904,
      "min": 4.54505161542,
      "max": 5.422736195420001
    },
    {
      "command": "pacquet@main",
      "mean": 4.59244399182,
      "stddev": 0.17085226524504393,
      "median": 4.529200233420001,
      "user": 1.9018255400000001,
      "system": 1.6551440399999997,
      "min": 4.41316137142,
      "max": 4.84150552342
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5614021774200006,
      "stddev": 0.14540114858797412,
      "median": 3.51640695342,
      "user": 1.5419875399999996,
      "system": 1.7060377399999997,
      "min": 3.3938312074200003,
      "max": 3.8046621054200003
    },
    {
      "command": "pnpr@main",
      "mean": 3.5892013059199996,
      "stddev": 0.13979937916446233,
      "median": 3.57132554092,
      "user": 1.84552814,
      "system": 1.9786375399999998,
      "min": 3.4155420114200004,
      "max": 3.9005153704200004
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 143.7 ± 6.9 136.5 158.2 1.00
pacquet@main 156.5 ± 10.8 139.4 177.2 1.09 ± 0.09
pnpr@HEAD 158.4 ± 7.8 146.8 169.9 1.10 ± 0.08
pnpr@main 258.6 ± 48.1 161.7 330.6 1.80 ± 0.35
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.14365760930000002,
      "stddev": 0.006909383832505652,
      "median": 0.1424753313,
      "user": 0.17585328888888888,
      "system": 0.14770432,
      "min": 0.1364784088,
      "max": 0.1582132388
    },
    {
      "command": "pacquet@main",
      "mean": 0.1565014959764706,
      "stddev": 0.010829733030000677,
      "median": 0.1587988888,
      "user": 0.19148181176470588,
      "system": 0.1573882611764706,
      "min": 0.1393943158,
      "max": 0.1771679458
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.15839561868888888,
      "stddev": 0.007766444996769564,
      "median": 0.1581016593,
      "user": 0.1747477333333333,
      "system": 0.1578714311111111,
      "min": 0.1468455488,
      "max": 0.1698613838
    },
    {
      "command": "pnpr@main",
      "mean": 0.25855258836249995,
      "stddev": 0.04814491417477378,
      "median": 0.2629269463,
      "user": 0.2988474,
      "system": 0.225557445,
      "min": 0.1617280698,
      "max": 0.3305596448
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review September 23, 2026 15:40
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Skip absent global package directories during bin ownership scans

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Skip missing package directories and dangling store links during global bin ownership scans.
• Preserve fail-closed errors for present packages with unreadable or invalid manifests.
• Cover Rust and TypeScript paths with unit and global-command regressions.
Diagram

graph TD
  A["Global commands"] --> B["Rust and TS scanners"] --> C{"Modules present?"}
  C -- "Yes" --> D["Dependency probe"] --> E{"Directory present?"}
  E -- "Yes" --> F["Read manifest"] --> H["Ownership result"]
  E -- "No" --> G["Skip dependency"] --> H
  C -- "No" --> H
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Classify ENOENT after manifest reads
  • ➕ Avoids an extra directory probe for healthy installed dependencies.
  • ➕ Keeps the common path centered on the existing manifest reader.
  • ➖ Requires a second probe after ENOENT to distinguish an absent directory from a missing manifest.
  • ➖ Complicates preservation of fail-closed behavior and diagnostic paths.
  • ➖ Would be harder to implement consistently across Rust capabilities and Node.js filesystem APIs.

Recommendation: Keep the explicit directory-probe approach. Although it adds one filesystem operation per dependency, global groups are small, and the approach clearly distinguishes uninstalled packages from corrupted manifests while preserving non-ENOENT errors consistently in both implementations.

Files changed (8) +280 / -36

Bug fix (2) +49 / -25
scan.rsSkip absent dependencies in Rust ownership scans +24/-13

Skip absent dependencies in Rust ownership scans

• Introduces an 'FsReadDir'-based directory probe for both 'node_modules' and individual dependency directories. Only 'NotFound' is treated as absent; other probe errors and manifest failures continue to abort ownership scanning.

pnpm/crates/global/src/scan.rs

scanGlobalPackages.tsSkip absent dependencies in TypeScript ownership scans +25/-12

Skip absent dependencies in TypeScript ownership scans

• Adds a shared 'dirExists' probe for the group modules directory and each declared dependency. ENOENT skips unavailable packages, while other filesystem errors and failures for manifests inside existing directories still surface.

pnpm11/global/packages/src/scanGlobalPackages.ts

Tests (5) +224 / -11
tests.rsPreserve missing-manifest diagnostic coverage +3/-2

Preserve missing-manifest diagnostic coverage

• Creates the dependency directory before testing a missing manifest, ensuring the test still exercises a present-but-incomplete package rather than the newly accepted absent-directory case.

pnpm/crates/cli/src/cli_args/global/tests.rs

ownership.rsExercise global commands with dangling package links +109/-1

Exercise global commands with dangling package links

• Adds Unix end-to-end tests proving global add and remove proceed when another group's package link points into a pruned store. Introduces a helper for replacing a dependency directory with a dangling symlink.

pnpm/crates/cli/tests/suite/global/ownership.rs

tests.rsCover absent and dangling dependencies in Rust +37/-8

Cover absent and dangling dependencies in Rust

• Adds unit tests confirming absent dependency directories and dangling links contribute no bins while readable dependencies remain represented. Updates missing-manifest coverage to use an existing dependency directory.

pnpm/crates/global/src/scan/tests.rs

getInstalledBinNames.test.tsTest TypeScript ownership scans for absent packages +24/-0

Test TypeScript ownership scans for absent packages

• Adds cases for declared aliases with absent directories and dangling store links. Both cases retain bins from healthy dependencies while omitting the unavailable package.

pnpm11/global/commands/test/getInstalledBinNames.test.ts

globalRemove.test.tsVerify removal ignores dangling survivor ownership +51/-0

Verify removal ignores dangling survivor ownership

• Adds a global-remove regression test showing that a surviving group with a dangling package link cannot protect a shared command shim from deletion.

pnpm11/global/commands/test/globalRemove.test.ts

Documentation (1) +7 / -0
global-scan-skips-absent-package-dirs.mdDocument global ownership recovery behavior +7/-0

Document global ownership recovery behavior

• Adds patch release notes for '@pnpm/global.packages', 'pnpm', and 'pacquet'. Explains that missing package directories and dangling store links no longer block global commands.

.changeset/global-scan-skips-absent-package-dirs.md

@qodo-code-review

qodo-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Large global commands flood disk work ✓ Resolved 🐞 Bug ➹ Performance
Description
getInstalledBinNames calls dirExists inside its unbounded Promise.all, adding a stat before
every package manifest read. getGlobalBinOwnership also scans groups concurrently, so large global
installations queue one extra filesystem request per dependency at once during add, update, and
remove.
Code

pnpm11/global/packages/src/scanGlobalPackages.ts[174]

+      if (!await dirExists(depDir)) return
Relevance

●● Moderate

Concurrency overhead is plausible, but similar performance optimization requests have been rejected
as subjective refactors.

PR-#15029

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added dependency probe performs fs.promises.stat, and both dependencies within a group and
groups within an ownership snapshot are dispatched with Promise.all, multiplying concurrent
filesystem work.

pnpm11/global/packages/src/scanGlobalPackages.ts[170-177]
pnpm11/global/packages/src/scanGlobalPackages.ts[189-198]
pnpm11/global/commands/src/binOwnership.ts[22-30]
pnpm11/pkg-manifest/reader/src/index.ts[24-37]

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 TypeScript ownership scan schedules an additional `stat` for every dependency on the successful path, and nested `Promise.all` calls can queue all those filesystem operations concurrently.

## Fix Focus Areas
- pnpm11/global/packages/src/scanGlobalPackages.ts[170-177]
- pnpm11/global/packages/src/scanGlobalPackages.ts[189-198]
- pnpm11/global/commands/src/binOwnership.ts[22-30]

## Recommended Fix
Read each dependency manifest directly on the normal path. If that read reports `ENOENT`, call `dirExists` to distinguish an absent dependency directory from a present directory with a missing manifest; skip only the former and rethrow the original error for the latter.

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


2. Large global commands scan twice ✓ Resolved 🐞 Bug ➹ Performance
Description
get_installed_bin_names_with_fs calls dir_exists for every declared dependency before reading
its manifest, and that helper opens the directory through FsReadDir. Global add, update, and
remove scan ownership before mutation, so an installation with N global dependencies now performs N
extra serialized directory opens during these commands.
Code

pnpm/crates/global/src/scan.rs[R170-172]

+        if !dir_exists::<Sys>(&dep_dir)? {
+            continue;
+        }
Relevance

●● Moderate

Performance concern is plausible, but no close historical precedent confirms rejecting this targeted
existence probe.

PR-#15029

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed loop invokes dir_exists before every manifest read, while the production capability
implements that probe using std::fs::read_dir; ownership snapshots are executed directly by the
global mutation preflight.

pnpm/crates/global/src/scan.rs[164-175]
pnpm/crates/global/src/scan.rs[185-194]
pnpm/crates/cmd-shim/src/capabilities.rs[231-240]
pnpm/crates/cli/src/cli_args/global/remove.rs[118-121]

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 Rust ownership scan opens every dependency directory before reading its manifest, adding one serialized filesystem operation per dependency to global add, update, and remove.

## Fix Focus Areas
- pnpm/crates/global/src/scan.rs[164-179]
- pnpm/crates/global/src/scan.rs[185-195]

## Recommended Fix
Attempt to read each dependency manifest directly on the normal path. Only when that read returns `NotFound`, probe `dep_dir`: continue if the directory is absent, but return the original manifest error if the directory still exists; continue propagating every other read or probe error.

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



Remediation recommended

3. Global scan docs narrate internals ✓ Resolved 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The getInstalledBinNames JSDoc describes the sequencing of the manifest read and directory probe
rather than stating only the function's behavioral guarantee. If that implementation changes while
its absent-directory behavior remains intact, the documentation becomes stale and misleads later
maintainers about required control flow.
Code

pnpm11/global/packages/src/scanGlobalPackages.ts[R162-163]

+ * bin. The directory is probed only after its manifest read fails with
+ * ENOENT, so a link pruned underneath the scan is skipped as absent.
Relevance

●●● Strong

Recent reviews accept removing implementation-narrating comments and refocusing documentation on
non-obvious behavioral contracts.

PR-#15314
PR-#15304

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713430 requires JSDoc to document contracts rather than re-describe implementation.
The cited JSDoc explicitly says the directory probe occurs only after the manifest read fails,
mirroring the function's try/catch control flow.

Rule 713430: JSDoc must document function contracts, not re-describe implementation
pnpm11/global/packages/src/scanGlobalPackages.ts[162-163]

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 `getInstalledBinNames` JSDoc narrates the order of internal filesystem operations instead of documenting the observable contract.

## Fix Focus Areas
- pnpm11/global/packages/src/scanGlobalPackages.ts[162-163]

## Recommended Fix
Replace the implementation sequence with a contract-focused statement, such as guaranteeing that dependencies removed during the scan are treated as absent.

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


4. Windows dangling links lack coverage ✓ Resolved 📜 Skill insight ▣ Testability
Description
The Rust dangling-link regression tests are guarded by #[cfg(unix)], so they never exercise the
changed directory probe on Windows. Windows resolves directory links through different APIs and
permissions, while the Rust scan now relies on that platform-specific result to decide whether
ownership is absent.
Code

pnpm/crates/global/src/scan/tests.rs[R142-144]

+#[cfg(unix)]
+#[test]
+fn installed_bin_names_treats_a_dangling_dependency_link_as_binless() {
Relevance

●● Moderate

Windows coverage is relevant, but no historical precedent establishes acceptance for this
platform-specific test request.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3365308 requires explicit Windows coverage for symlink-handling changes. Both newly
added Rust dangling-link tests are Unix-only, including the unit test directly covering the modified
scanner.

pnpm/crates/global/src/scan/tests.rs[142-155]
pnpm/crates/cli/tests/suite/global/ownership.rs[472-537]
Skill: review-code

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 Rust regression test for dangling dependency directories runs only on Unix, leaving the changed link-handling behavior unverified on Windows.

## Fix Focus Areas
- pnpm/crates/global/src/scan/tests.rs[142-155]
- pnpm/crates/cli/tests/suite/global/ownership.rs[472-537]

## Recommended Fix
Add a Windows-specific regression that creates a dangling directory junction or equivalent directory link, invokes the Rust ownership scan, and asserts that existing package bins remain while the dangling dependency contributes none.

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



Informational

5. One release note mixes release lines 📘 Rule violation § Compliance
Description
.changeset/global-scan-skips-absent-package-dirs.md places the TypeScript targets
@pnpm/global.packages and pnpm in the same frontmatter as the Rust target pacquet. Any later
wording or targeting difference between versions must now replace a note that also belongs to the
other release line.
Code

.changeset/global-scan-skips-absent-package-dirs.md[R2-4]

+"@pnpm/global.packages": patch
+"pnpm": patch
+"pacquet": patch
Relevance

● Weak

Recent close precedents reject splitting pnpm and pacquet changesets despite the same compliance
rule.

PR-#15237
PR-#15314
PR-#15320

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713436 requires separate changeset files when a PR changes both the TypeScript pnpm
v11 implementation and Rust pnpm v12 implementation. The new changeset instead lists both release
lines together in one frontmatter block.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/global-scan-skips-absent-package-dirs.md[1-7]

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 changeset combines TypeScript v11 package targets and the Rust v12 target even though changes affecting both implementations require release-line-specific changesets.

## Fix Focus Areas
- .changeset/global-scan-skips-absent-package-dirs.md[1-7]

## Recommended Fix
Keep `@pnpm/global.packages` and `pnpm` in a TypeScript changeset, and create a separate changeset containing only `pacquet` for the Rust implementation. Use release-note text matching each target's observable behavior.

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


6. Two symlink calls omit trailing commas 📘 Rule violation ⚙ Maintainability
Description
The added fs.symlink and fs.symlinkSync argument lists leave their final process.platform
arguments without trailing commas. Both calls span multiple lines in TypeScript regression tests, so
adding another argument requires editing the preceding line as well.
Code

pnpm11/global/commands/test/getInstalledBinNames.test.ts[R39-42]

+    path.join(info.installDir, 'store/links/pruned/node_modules/pruned'),
+    path.join(info.installDir, 'node_modules', 'pruned'),
+    process.platform === 'win32' ? 'junction' : 'dir'
+  )
Relevance

● Weak

A recent close precedent rejected the same trailing-comma style finding in multiline TypeScript
calls.

PR-#13428

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713434 requires trailing commas on the final items of multi-line TypeScript argument
lists. The two newly added symlink calls are multi-line constructs whose final arguments have no
commas.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/global/commands/test/getInstalledBinNames.test.ts[38-42]
pnpm11/global/commands/test/globalRemove.test.ts[237-241]

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

## Issue description
Two new multi-line TypeScript symlink calls omit the required trailing comma after their final arguments.

## Fix Focus Areas
- pnpm11/global/commands/test/getInstalledBinNames.test.ts[38-42]
- pnpm11/global/commands/test/globalRemove.test.ts[237-241]

## Recommended Fix
Add a comma after each final `process.platform === 'win32' ? 'junction' : 'dir'` argument without changing the calls' behavior.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/update (sha: fcaa952e)
  Explored: repo: pnpm/setup (sha: fbda4c85)
  Explored: repo: pnpm/get.pnpm.io (sha: 2f7857da)
  Explored: repo: pnpm/logger (sha: 3c7188c0)
Review mode: 🚀 Fast: The push makes a small, localized behavioral adjustment in two parallel implementations to ignore only confirmed absent dependency directories while preserving other errors.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Finding overflow, which tucks the rest behind 'View more'

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 0f5a305

Results up to commit cd6757d ⚖️ Balanced


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


Action required
1. Large global commands flood disk work ✓ Resolved 🐞 Bug ➹ Performance
Description
getInstalledBinNames calls dirExists inside its unbounded Promise.all, adding a stat before
every package manifest read. getGlobalBinOwnership also scans groups concurrently, so large global
installations queue one extra filesystem request per dependency at once during add, update, and
remove.
Code

pnpm11/global/packages/src/scanGlobalPackages.ts[174]

+      if (!await dirExists(depDir)) return
Relevance

●● Moderate

Concurrency overhead is plausible, but similar performance optimization requests have been rejected
as subjective refactors.

PR-#15029

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added dependency probe performs fs.promises.stat, and both dependencies within a group and
groups within an ownership snapshot are dispatched with Promise.all, multiplying concurrent
filesystem work.

pnpm11/global/packages/src/scanGlobalPackages.ts[170-177]
pnpm11/global/packages/src/scanGlobalPackages.ts[189-198]
pnpm11/global/commands/src/binOwnership.ts[22-30]
pnpm11/pkg-manifest/reader/src/index.ts[24-37]

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 TypeScript ownership scan schedules an additional `stat` for every dependency on the successful path, and nested `Promise.all` calls can queue all those filesystem operations concurrently.

## Fix Focus Areas
- pnpm11/global/packages/src/scanGlobalPackages.ts[170-177]
- pnpm11/global/packages/src/scanGlobalPackages.ts[189-198]
- pnpm11/global/commands/src/binOwnership.ts[22-30]

## Recommended Fix
Read each dependency manifest directly on the normal path. If that read reports `ENOENT`, call `dirExists` to distinguish an absent dependency directory from a present directory with a missing manifest; skip only the former and rethrow the original error for the latter.

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


2. Large global commands scan twice ✓ Resolved 🐞 Bug ➹ Performance
Description
get_installed_bin_names_with_fs calls dir_exists for every declared dependency before reading
its manifest, and that helper opens the directory through FsReadDir. Global add, update, and
remove scan ownership before mutation, so an installation with N global dependencies now performs N
extra serialized directory opens during these commands.
Code

pnpm/crates/global/src/scan.rs[R170-172]

+        if !dir_exists::<Sys>(&dep_dir)? {
+            continue;
+        }
Relevance

●● Moderate

Performance concern is plausible, but no close historical precedent confirms rejecting this targeted
existence probe.

PR-#15029

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed loop invokes dir_exists before every manifest read, while the production capability
implements that probe using std::fs::read_dir; ownership snapshots are executed directly by the
global mutation preflight.

pnpm/crates/global/src/scan.rs[164-175]
pnpm/crates/global/src/scan.rs[185-194]
pnpm/crates/cmd-shim/src/capabilities.rs[231-240]
pnpm/crates/cli/src/cli_args/global/remove.rs[118-121]

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 Rust ownership scan opens every dependency directory before reading its manifest, adding one serialized filesystem operation per dependency to global add, update, and remove.

## Fix Focus Areas
- pnpm/crates/global/src/scan.rs[164-179]
- pnpm/crates/global/src/scan.rs[185-195]

## Recommended Fix
Attempt to read each dependency manifest directly on the normal path. Only when that read returns `NotFound`, probe `dep_dir`: continue if the directory is absent, but return the original manifest error if the directory still exists; continue propagating every other read or probe error.

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



Remediation recommended
3. Windows dangling links lack coverage ✓ Resolved 📜 Skill insight ▣ Testability
Description
The Rust dangling-link regression tests are guarded by #[cfg(unix)], so they never exercise the
changed directory probe on Windows. Windows resolves directory links through different APIs and
permissions, while the Rust scan now relies on that platform-specific result to decide whether
ownership is absent.
Code

pnpm/crates/global/src/scan/tests.rs[R142-144]

+#[cfg(unix)]
+#[test]
+fn installed_bin_names_treats_a_dangling_dependency_link_as_binless() {
Relevance

●● Moderate

Windows coverage is relevant, but no historical precedent establishes acceptance for this
platform-specific test request.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3365308 requires explicit Windows coverage for symlink-handling changes. Both newly
added Rust dangling-link tests are Unix-only, including the unit test directly covering the modified
scanner.

pnpm/crates/global/src/scan/tests.rs[142-155]
pnpm/crates/cli/tests/suite/global/ownership.rs[472-537]
Skill: review-code

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 Rust regression test for dangling dependency directories runs only on Unix, leaving the changed link-handling behavior unverified on Windows.

## Fix Focus Areas
- pnpm/crates/global/src/scan/tests.rs[142-155]
- pnpm/crates/cli/tests/suite/global/ownership.rs[472-537]

## Recommended Fix
Add a Windows-specific regression that creates a dangling directory junction or equivalent directory link, invokes the Rust ownership scan, and asserts that existing package bins remain while the dangling dependency contributes none.

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



Informational
4. One release note mixes release lines 📘 Rule violation § Compliance
Description
.changeset/global-scan-skips-absent-package-dirs.md places the TypeScript targets
@pnpm/global.packages and pnpm in the same frontmatter as the Rust target pacquet. Any later
wording or targeting difference between versions must now replace a note that also belongs to the
other release line.
Code

.changeset/global-scan-skips-absent-package-dirs.md[R2-4]

+"@pnpm/global.packages": patch
+"pnpm": patch
+"pacquet": patch
Relevance

● Weak

Recent close precedents reject splitting pnpm and pacquet changesets despite the same compliance
rule.

PR-#15237
PR-#15314
PR-#15320

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713436 requires separate changeset files when a PR changes both the TypeScript pnpm
v11 implementation and Rust pnpm v12 implementation. The new changeset instead lists both release
lines together in one frontmatter block.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/global-scan-skips-absent-package-dirs.md[1-7]

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 changeset combines TypeScript v11 package targets and the Rust v12 target even though changes affecting both implementations require release-line-specific changesets.

## Fix Focus Areas
- .changeset/global-scan-skips-absent-package-dirs.md[1-7]

## Recommended Fix
Keep `@pnpm/global.packages` and `pnpm` in a TypeScript changeset, and create a separate changeset containing only `pacquet` for the Rust implementation. Use release-note text matching each target's observable behavior.

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


5. Two symlink calls omit trailing commas 📘 Rule violation ⚙ Maintainability
Description
The added fs.symlink and fs.symlinkSync argument lists leave their final process.platform
arguments without trailing commas. Both calls span multiple lines in TypeScript regression tests, so
adding another argument requires editing the preceding line as well.
Code

pnpm11/global/commands/test/getInstalledBinNames.test.ts[R39-42]

+    path.join(info.installDir, 'store/links/pruned/node_modules/pruned'),
+    path.join(info.installDir, 'node_modules', 'pruned'),
+    process.platform === 'win32' ? 'junction' : 'dir'
+  )
Relevance

● Weak

A recent close precedent rejected the same trailing-comma style finding in multiline TypeScript
calls.

PR-#13428

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713434 requires trailing commas on the final items of multi-line TypeScript argument
lists. The two newly added symlink calls are multi-line constructs whose final arguments have no
commas.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/global/commands/test/getInstalledBinNames.test.ts[38-42]
pnpm11/global/commands/test/globalRemove.test.ts[237-241]

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

## Issue description
Two new multi-line TypeScript symlink calls omit the required trailing comma after their final arguments.

## Fix Focus Areas
- pnpm11/global/commands/test/getInstalledBinNames.test.ts[38-42]
- pnpm11/global/commands/test/globalRemove.test.ts[237-241]

## Recommended Fix
Add a comma after each final `process.platform === 'win32' ? 'junction' : 'dir'` argument without changing the calls' behavior.

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


Grey Divider

Qodo Logo

Comment thread pnpm/crates/global/src/scan.rs Resolved
@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.

@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no outstanding findings in the scoring set.

Reviews (3) · Last reviewed commit: "docs(global): keep the bin-ownership con..."

Comment thread pnpm/crates/global/src/scan.rs Resolved
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 23, 2026
…d fails

Read each declared dependency's manifest first and probe its directory only
when the read fails with NotFound. The happy path costs no extra filesystem
call per dependency, and a link pruned between the two reads is skipped as
absent instead of surfacing the manifest error.

The dangling-link unit test now creates the link through pnpm_fs::symlink_dir
so it also runs on Windows, where global groups link packages with junctions.

The changeset keeps only the user-visible behavior.
@zkochan

zkochan commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Review round on cd6757d, addressed in 88634a3:

  • Qodo 1 and 2, Greptile P1 (per-dependency probe cost and the prune race): both stacks now read the manifest first and probe the directory only on ENOENT. Threads resolved.
  • Greptile P2 (changeset rationale): trimmed to the user-visible behavior. Thread resolved.
  • Qodo 3 (Windows coverage): the dangling-link unit test now creates its link through the repository's cross-platform symlink_dir helper and runs on every platform. The e2e ownership suite stays Unix-only like its neighbors.
  • Qodo 4 (one changeset spanning pnpm and pacquet): declined. AGENTS.md allows one changeset for several release lines when the same release-note text applies to every target, which is the case here.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 88634a3

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

Comment thread pnpm/crates/global/src/scan/tests.rs Resolved
Comment thread pnpm/crates/global/src/scan.rs Resolved
The API docs state what the scan guarantees. The reason the directory is
probed after the manifest read rather than before, a link pruned while the
scan runs, stays as an inline comment at the probe.
@zkochan

zkochan commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Review round on 88634a3, addressed in 0f5a305:

  • Greptile P2 and Qodo 3 (docs narrate the probe order): fixed. The API docs keep only the ownership contract; the pruned-link reason is an inline comment at the probe. Thread resolved.
  • Greptile P1 (Windows junction setup): declined with evidence on the thread. junction 2.0.0 does not require the target to exist, and the Windows CI test job passed the test on 88634a3. Thread resolved.
  • Qodo 5 (one changeset spanning release lines): declined as before, per the AGENTS.md changeset rule.
  • Qodo 6 (trailing commas in multi-line TypeScript calls): declined. The repository's lint ran with --fix on these files and does not add them, and the same finding was rejected on feat(update): select global groups interactively #13428.

CodeRabbit reports it has used its free OSS review quota, so it has not re-reviewed past cd6757d.


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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 0f5a305

@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 f7818b1 into main Sep 23, 2026
42 of 43 checks passed
@zkochan
zkochan deleted the fix-self-install branch September 23, 2026 16:44
u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
…hip (pnpm#15381)

Enumerating a global group's bins failed closed on every declared dependency
whose manifest could not be read. A group whose package directory is a link
into the global virtual store that no longer holds the package therefore
aborted every `pnpm add -g`, `pnpm update -g`, and `pnpm remove -g` that had
to scan the other groups, with ERR_PNPM_PACKAGE_MANIFEST_IO_ERROR naming the
dangling manifest path. The pnpm install script hit this while replacing the
existing pnpm CLI group on a machine whose store had been pruned, so pnpm
could not be updated at all.

A dependency whose directory under `node_modules` is absent is definitively
not installed, the same way a group without `node_modules` is: no bin can
resolve through a directory that is not there. Such a dependency now reads
as owning no bins. A directory that exists but lacks a readable, valid
manifest still fails closed, so unknown ownership is never treated as
unowned, and every non-ENOENT probe error still surfaces.

Both stacks probe the dependency directory before reading its manifest. The
Rust probe goes through the FsReadDir capability so the fake-filesystem unit
tests keep exercising the per-manifest error paths.

The unit test that models one missing manifest now creates the dependency
directory first, since an absent directory is the case being relaxed. New
unit and e2e tests cover an absent directory and a dangling link in each
stack.
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.

2 participants