Skip to content

fix(cmd-shim): fall back to PATH for shim helpers - #16379

Merged
zkochan merged 2 commits into
pnpm:mainfrom
Newspicel:fix/shim-helpers-without-default-path
Sep 29, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
Newspicel:fix/shim-helpers-without-default-path

Conversation

@Newspicel

@Newspicel Newspicel commented Sep 29, 2026 •

Copy link
Copy Markdown

Shims fall back to the filtered PATH when command -p finds no helper, as in a Nix build sandbox.

A helper comes from PATH only when PATH has it, because the bash 3.2 that macOS ships as sh answers command -p -v from PATH.

Closes #16377


Helped by an agent (Claude-Code, opus5.5)


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

Summary by CodeRabbit

  • Bug Fixes
    • POSIX launchers and shims can now find required system helpers when they are unavailable on the default command path, including in restricted environments such as Nix builds.
    • Symlink-based aliases continue to launch the correct executable, while helper lookup excludes relative paths and node_modules entries.
    • Reinstalling replaces existing shims that lack the updated helper lookup behavior.

@welcome

welcome Bot commented Sep 29, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@coderabbitai

coderabbitai Bot commented Sep 29, 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: 567b1e32-f7f3-472c-bc85-a1d10c4fb490

📥 Commits

Reviewing files that changed from the base of the PR and between 29cbda9 and 768cb89.

📒 Files selected for processing (16)
  • pnpm/crates/cli/src/cli_args/setup.rs
  • pnpm/crates/cmd-shim/src/shim/sh.rs
  • pnpm/crates/cmd-shim/src/shim/tests.rs
  • pnpm/npm/pnpm/pn
  • pnpm/npm/pnpm/pnpm
  • pnpm/npm/pnpm/pnpx
  • pnpm/npm/pnpm/pnx
  • pnpm11/bins/cmd-shim/src/index.ts
  • pnpm11/bins/cmd-shim/test/e2e.test.js
  • pnpm11/bins/cmd-shim/test/e2e.test.js.snapshot
  • pnpm11/bins/cmd-shim/test/test.js.snapshot
  • pnpm11/engine/pm/commands/src/setup/setup.ts
  • pnpm11/pnpm/artifacts/exe/pn
  • pnpm11/pnpm/artifacts/exe/pnpx
  • pnpm11/pnpm/artifacts/exe/pnx
  • pnpm11/pnpm/artifacts/exe/prepare.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

POSIX shims and launchers now use run_helper to select utilities from the default command path or the filtered caller PATH. Tests cover shim generation, relinking, and alias execution when the default path lacks a helper.

Changes

POSIX helper lookup

Layer / File(s) Summary
Generated shim helper resolution
pnpm/crates/cmd-shim/src/shim/*, pnpm11/bins/cmd-shim/*
Generated shims route utility calls through run_helper. Tests and snapshots cover helper lookup, path conversion, and platform detection.
Shim hardening and relinking
pnpm/crates/cmd-shim/src/link_bins/*, pnpm11/bins/linker/*
The hardened-shim signature recognizes the helper calls. Tests check that relinking replaces older shims and preserves their target marker.
Package launcher helper resolution
pnpm/npm/pnpm/*, pnpm11/engine/pm/commands/src/setup/setup.ts, pnpm11/pnpm/artifacts/exe/*, .changeset/shim-helpers-without-default-path.md
Packaged launchers and setup scripts use run_helper for readlink. Tests cover alias execution when the default helper path lacks readlink. The Changeset marks six packages for patch releases.
CLI alias helper resolution
pnpm/crates/cli/src/cli_args/setup.*
The Rust CLI alias resolver uses run_helper for readlink. A Unix test covers symlinked aliases when command -p cannot find it.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
[16377] POSIX shims run in Nix builds where command -p cannot find utilities such as sed. ✅

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

Merge Risk: ⚪ Minimal · up to 768cb

Shims and launchers now fall back to the filtered PATH when the default path lacks a helper, which fixes Nix build sandboxes. No merge-blocking risk was found.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 768cb

When a helper is unavailable on the system’s default command path, a shim can run one from the caller’s PATH. The PATH filter blocks obvious unsafe entries, but a verified security issue remains in how it treats symlinked paths. Exposure depends on the environment and control of PATH entries.

Retained concerns

  • Medium · security · inferred: Text-only filtering of caller PATH entries does not prevent a retained absolute entry from resolving through a symlink to an excluded helper location. Where default-path lookup cannot provide the helper, that executable can influence shim self-resolution or subsequent dispatch.
Security review details

Security Blast Radius

  • inferred — The independently affected unit is a shim or launcher invoked with an attacker-influenced eligible PATH entry in an environment where the default-path helper is unavailable. The shared generated form extends the condition beyond one executable; tenant or elevated-service exposure is not established.

Security Findings and Attack Paths

  • inferred — An absolute PATH directory accepted by the textual filter can resolve through a symlink to an otherwise excluded helper. If fallback selects it, a substituted readlink, sed, printf, or uname can affect resolution before the intended target runs.

Trust Boundaries and Controls

  • observed — Default-path preference, exclusion of relative and visibly node_modules PATH entries, bounded symlink traversal, and the launcher’s final regular-file check limit the attack path; none authenticates the resolved provenance of an accepted helper.

Resilience and Maintainability Implications

  • observed — The scoped end-to-end tests invoke generated temporary shims with decoy helpers, not the packaged pn launcher; launcher-specific self-resolution and final handoff are not established by that suite.

Hardening Proposals

  • proposed — Define whether fallback helpers may come from caller-controlled directories, including symlinked directories, and enforce that policy consistently across generated and packaged scripts. Exercise the packaged launchers directly under missing-default-helper conditions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • 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/bins/cmd-shim/src/index.ts

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

pnpm11/bins/cmd-shim/test/e2e.test.js

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

pnpm11/engine/pm/commands/src/setup/setup.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 1 others

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 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.15%. Comparing base (b8d53ce) to head (768cb89).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16379   +/-   ##
=======================================
  Coverage   92.15%   92.15%           
=======================================
  Files        1513     1513           
  Lines      203838   203838           
=======================================
+ Hits       187843   187848    +5     
+ Misses      15995    15990    -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 29, 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 2408.89 ms 2463.74 ms 2.3% 120.44 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1604.84 ms 1406.71 ms -12.3% 80.24 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 243.86 ms 242.22 ms -0.7% 12.19 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 276.29 ms 289.41 ms 4.7% 13.81 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 9.77 ms 14.00 ms 43.3% 2.00 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pnpr 14.04 ms 11.97 ms -14.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 8.85 ms 8.87 ms 0.2% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 8.81 ms 8.97 ms 1.7% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2550.03 ms 2761.81 ms 8.3% 127.50 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-cold-store pnpr 1491.41 ms 1541.28 ms 3.3% 74.57 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 577.96 ms 592.49 ms 2.5% 28.90 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 355.95 ms 356.01 ms 0.0% 17.80 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1752.48 ms 1787.56 ms 2.0% 87.62 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 352.69 ms 354.39 ms 0.5% 17.63 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 249.20 ms 254.08 ms 2.0% 12.46 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 93.57 ms 95.48 ms 2.0% 4.68 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 1100.93 ms 984.71 ms -10.6% 55.05 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 314.33 ms 279.90 ms -11.0% 15.72 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4407.44 ms 4422.74 ms 0.3% 220.37 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3403.05 ms 3432.56 ms 0.9% 170.15 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 326.79 ms 350.49 ms 7.3% 16.34 ms Inconclusive (overlapping samples)
gvs-fresh-restore-hot-cache-hot-store pnpr 310.45 ms 392.50 ms 26.4% 15.52 ms Inconclusive (overlapping samples)

Integrated-Benchmark Report (Linux)

Commit: 768cb89ca837

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.492 ± 0.155 2.312 2.725 1.71 ± 0.18
pacquet@main 2.483 ± 0.156 2.335 2.687 1.71 ± 0.18
pnpr@HEAD 1.456 ± 0.126 1.338 1.709 1.00
pnpr@main 1.574 ± 0.121 1.394 1.734 1.08 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.49189352278,
      "stddev": 0.15459793639768324,
      "median": 2.46373855238,
      "user": 1.56849662,
      "system": 1.5351875599999996,
      "min": 2.3124970513800003,
      "max": 2.72525259538
    },
    {
      "command": "pacquet@main",
      "mean": 2.48313638838,
      "stddev": 0.15566340113534965,
      "median": 2.40888653888,
      "user": 1.63295812,
      "system": 1.55834436,
      "min": 2.33513338338,
      "max": 2.6871191693800003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.45625443068,
      "stddev": 0.12621210973540767,
      "median": 1.40670757438,
      "user": 1.56465642,
      "system": 1.54189726,
      "min": 1.3376200033799999,
      "max": 1.70872479638
    },
    {
      "command": "pnpr@main",
      "mean": 1.5740586939799999,
      "stddev": 0.12091523232044747,
      "median": 1.6048351463800001,
      "user": 1.55413662,
      "system": 1.51262956,
      "min": 1.3937080953799998,
      "max": 1.7339734333799999
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 245.1 ± 18.6 221.9 285.8 1.00
pacquet@main 259.9 ± 36.4 217.4 323.5 1.06 ± 0.17
pnpr@HEAD 291.1 ± 16.2 267.9 325.0 1.19 ± 0.11
pnpr@main 282.0 ± 18.0 264.3 317.5 1.15 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24509908998,
      "stddev": 0.018614653939949783,
      "median": 0.24221899888000004,
      "user": 0.28530604,
      "system": 0.5727742399999999,
      "min": 0.22187970138000002,
      "max": 0.28576095538
    },
    {
      "command": "pacquet@main",
      "mean": 0.25994478198000004,
      "stddev": 0.036419092658273824,
      "median": 0.24386250938000004,
      "user": 0.28248584,
      "system": 0.6098521399999999,
      "min": 0.21744990938000003,
      "max": 0.32352506538
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29110070608,
      "stddev": 0.016154216698962606,
      "median": 0.28940586488,
      "user": 0.31297674,
      "system": 0.6291288399999999,
      "min": 0.26792765038,
      "max": 0.32495736638
    },
    {
      "command": "pnpr@main",
      "mean": 0.28200125618,
      "stddev": 0.017957874255832177,
      "median": 0.27629328938,
      "user": 0.30033304000000005,
      "system": 0.64285654,
      "min": 0.26432988038,
      "max": 0.31754280338
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 14.5 ± 2.8 9.6 30.1 1.41 ± 0.39
pacquet@main 10.3 ± 2.1 7.5 19.7 1.00
pnpr@HEAD 12.4 ± 2.9 8.0 21.1 1.21 ± 0.37
pnpr@main 14.3 ± 2.2 10.5 21.5 1.39 ± 0.35
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.014532021547289721,
      "stddev": 0.0027590930134578358,
      "median": 0.01400338408,
      "user": 0.008116320186915885,
      "system": 0.0078083719626168184,
      "min": 0.009593002580000001,
      "max": 0.03005185158
    },
    {
      "command": "pacquet@main",
      "mean": 0.010277668255889334,
      "stddev": 0.0020684486920715746,
      "median": 0.00977334958,
      "user": 0.006100851936758896,
      "system": 0.0051183466403162065,
      "min": 0.00746436858,
      "max": 0.019699866580000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.01238874064920415,
      "stddev": 0.0029033272983251136,
      "median": 0.01196725558,
      "user": 0.006700311487889272,
      "system": 0.006866085813148789,
      "min": 0.00804943758,
      "max": 0.021111814580000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.014317888426153846,
      "stddev": 0.0021882053270693034,
      "median": 0.01404405508,
      "user": 0.007806564615384614,
      "system": 0.007902034615384614,
      "min": 0.010450750580000001,
      "max": 0.02151568258
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 9.2 ± 1.1 8.0 15.6 1.00
pacquet@main 9.3 ± 1.2 8.0 14.7 1.01 ± 0.18
pnpr@HEAD 9.3 ± 1.1 8.0 14.6 1.01 ± 0.17
pnpr@main 9.2 ± 1.1 8.0 14.8 1.00 ± 0.17
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009178255312824433,
      "stddev": 0.001081999151918867,
      "median": 0.00886698708,
      "user": 0.005303034427480913,
      "system": 0.004771453893129773,
      "min": 0.00800453258,
      "max": 0.015582349580000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.009294934501933094,
      "stddev": 0.001224357161829934,
      "median": 0.00885347758,
      "user": 0.005207036282527877,
      "system": 0.004996443345724907,
      "min": 0.00797281558,
      "max": 0.014655309580000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009305324906923075,
      "stddev": 0.001140075227059171,
      "median": 0.00896583258,
      "user": 0.005371919999999999,
      "system": 0.004840169153846155,
      "min": 0.00800780358,
      "max": 0.01464491958
    },
    {
      "command": "pnpr@main",
      "mean": 0.009198831698773939,
      "stddev": 0.0011062747325741246,
      "median": 0.00881204158,
      "user": 0.0051525479693486625,
      "system": 0.004925681226053637,
      "min": 0.008039042580000001,
      "max": 0.01482733058
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.781 ± 0.128 2.582 2.979 1.84 ± 0.16
pacquet@main 2.558 ± 0.061 2.480 2.684 1.70 ± 0.13
pnpr@HEAD 1.539 ± 0.107 1.414 1.703 1.02 ± 0.10
pnpr@main 1.508 ± 0.106 1.387 1.656 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7805619152800007,
      "stddev": 0.12788843565088454,
      "median": 2.7618053591800003,
      "user": 2.69020936,
      "system": 2.1018500199999997,
      "min": 2.58166079318,
      "max": 2.9789720661800003
    },
    {
      "command": "pacquet@main",
      "mean": 2.5580615499800006,
      "stddev": 0.06132216325409298,
      "median": 2.55002719318,
      "user": 2.06631136,
      "system": 1.58238742,
      "min": 2.4802945591800003,
      "max": 2.6841412571800003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5386585497799998,
      "stddev": 0.10736265269629582,
      "median": 1.5412776296800001,
      "user": 1.2392167600000001,
      "system": 1.28593512,
      "min": 1.41360744418,
      "max": 1.70273586918
    },
    {
      "command": "pnpr@main",
      "mean": 1.50770402578,
      "stddev": 0.10645255463220925,
      "median": 1.4914106236800002,
      "user": 1.1559384599999998,
      "system": 1.28823052,
      "min": 1.38692378618,
      "max": 1.65579639818
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 601.0 ± 38.4 557.1 674.1 1.68 ± 0.13
pacquet@main 579.5 ± 27.2 542.4 633.6 1.62 ± 0.10
pnpr@HEAD 357.1 ± 14.6 340.3 382.8 1.00
pnpr@main 358.7 ± 6.8 348.3 370.7 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6010288988400001,
      "stddev": 0.03844781744514698,
      "median": 0.59249072924,
      "user": 0.8478261999999999,
      "system": 1.0471500599999999,
      "min": 0.5571166857400001,
      "max": 0.6741316457400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.57953937154,
      "stddev": 0.027181918598858705,
      "median": 0.57795559374,
      "user": 0.7910290999999999,
      "system": 1.0525783599999998,
      "min": 0.54236206674,
      "max": 0.63362781674
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.35705474684,
      "stddev": 0.014602745004778896,
      "median": 0.35600615974000005,
      "user": 0.33043999999999996,
      "system": 0.77960916,
      "min": 0.34027775874,
      "max": 0.38276018374000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.35874242194,
      "stddev": 0.006840577592967302,
      "median": 0.35594814474,
      "user": 0.33783090000000005,
      "system": 0.7519663600000001,
      "min": 0.34830456674,
      "max": 0.37072271574000004
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.804 ± 0.046 1.759 1.914 5.05 ± 0.23
pacquet@main 1.749 ± 0.024 1.707 1.792 4.90 ± 0.20
pnpr@HEAD 0.359 ± 0.012 0.348 0.387 1.01 ± 0.05
pnpr@main 0.357 ± 0.014 0.341 0.383 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.8040871206999998,
      "stddev": 0.045600101390306506,
      "median": 1.7875623108,
      "user": 1.3151697399999998,
      "system": 1.2366797200000001,
      "min": 1.7594734823,
      "max": 1.9140077163
    },
    {
      "command": "pacquet@main",
      "mean": 1.7492195631,
      "stddev": 0.02395728963537868,
      "median": 1.7524757083,
      "user": 1.24117864,
      "system": 1.16942132,
      "min": 1.7067218913,
      "max": 1.7923187393000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3593873585,
      "stddev": 0.011879687486888658,
      "median": 0.3543857788,
      "user": 0.33213174,
      "system": 0.6940792200000001,
      "min": 0.3481507513,
      "max": 0.3869222023
    },
    {
      "command": "pnpr@main",
      "mean": 0.356979798,
      "stddev": 0.013706167727036082,
      "median": 0.3526917848,
      "user": 0.32808664000000004,
      "system": 0.69123082,
      "min": 0.3413687823,
      "max": 0.3828329883
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 250.5 ± 12.5 227.2 267.3 2.67 ± 0.15
pacquet@main 253.4 ± 17.8 232.4 280.9 2.70 ± 0.20
pnpr@HEAD 95.7 ± 3.2 90.3 102.8 1.02 ± 0.04
pnpr@main 93.9 ± 2.5 88.5 100.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25048114370999996,
      "stddev": 0.012541852753583977,
      "median": 0.25408013146,
      "user": 0.23267536,
      "system": 0.09588706666666665,
      "min": 0.22719305296,
      "max": 0.26730592196
    },
    {
      "command": "pacquet@main",
      "mean": 0.25339737476,
      "stddev": 0.01777214756720258,
      "median": 0.24920302796000005,
      "user": 0.23732485999999997,
      "system": 0.089541,
      "min": 0.23243225596,
      "max": 0.28087115996
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09568018530482761,
      "stddev": 0.003244036130955579,
      "median": 0.09547505096,
      "user": 0.03433887724137931,
      "system": 0.017068951724137926,
      "min": 0.09031480496,
      "max": 0.10282005096
    },
    {
      "command": "pnpr@main",
      "mean": 0.09391657939749999,
      "stddev": 0.0025366532211570023,
      "median": 0.09356554246000001,
      "user": 0.03460029750000001,
      "system": 0.01463199375,
      "min": 0.08851331996,
      "max": 0.10018279596
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 958.2 ± 93.8 798.3 1094.8 1.00
pacquet@main 1083.2 ± 175.5 867.7 1329.1 1.13 ± 0.21
pnpm@HEAD 3128.9 ± 63.3 3012.9 3214.2 3.27 ± 0.33
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.9582401157733335,
      "stddev": 0.0937515855189032,
      "median": 0.9847147814400001,
      "user": 0.9992611266666663,
      "system": 0.31460855777777774,
      "min": 0.7982543354400001,
      "max": 1.09484252144
    },
    {
      "command": "pacquet@main",
      "mean": 1.0832301962177777,
      "stddev": 0.17546328748147866,
      "median": 1.10093216844,
      "user": 1.1622307933333333,
      "system": 0.32358233555555554,
      "min": 0.8677221714400001,
      "max": 1.32906954344
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.128861384217777,
      "stddev": 0.06334704227457272,
      "median": 3.1345438144399997,
      "user": 4.640683015555555,
      "system": 0.23868589111111113,
      "min": 3.01286242644,
      "max": 3.21424495644
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 288.1 ± 36.5 244.2 355.3 1.00
pacquet@main 304.3 ± 25.0 264.1 336.7 1.06 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.28814950664000005,
      "stddev": 0.036519442037934474,
      "median": 0.27990211774000007,
      "user": 0.24554782,
      "system": 0.10060348,
      "min": 0.24417121924000001,
      "max": 0.35529510424000005
    },
    {
      "command": "pacquet@main",
      "mean": 0.30427923954,
      "stddev": 0.02502444039275711,
      "median": 0.3143295487400001,
      "user": 0.24346271999999997,
      "system": 0.12555378,
      "min": 0.26407614324000006,
      "max": 0.33666872624000005
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.505 ± 0.166 4.350 4.819 1.30 ± 0.06
pacquet@main 4.430 ± 0.057 4.373 4.554 1.28 ± 0.05
pnpr@HEAD 3.474 ± 0.111 3.390 3.743 1.00 ± 0.05
pnpr@main 3.464 ± 0.116 3.370 3.710 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.505364103019999,
      "stddev": 0.16612984136508566,
      "median": 4.42274080692,
      "user": 1.67077384,
      "system": 1.559327,
      "min": 4.35025917342,
      "max": 4.81920908142
    },
    {
      "command": "pacquet@main",
      "mean": 4.4304219286199995,
      "stddev": 0.05699660754916484,
      "median": 4.407444333919999,
      "user": 1.65910674,
      "system": 1.6077744999999997,
      "min": 4.3725310004199995,
      "max": 4.55372140142
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.47396050892,
      "stddev": 0.11085409390636872,
      "median": 3.43255800792,
      "user": 1.44812214,
      "system": 1.4477854999999997,
      "min": 3.39043533042,
      "max": 3.74271321542
    },
    {
      "command": "pnpr@main",
      "mean": 3.46373282162,
      "stddev": 0.1158868669746853,
      "median": 3.40304592792,
      "user": 1.4515891399999998,
      "system": 1.4458800999999997,
      "min": 3.3697268764199997,
      "max": 3.70984883142
    }
  ]
}

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 345.7 ± 20.5 315.8 372.5 1.08 ± 0.19
pacquet@main 336.3 ± 36.3 297.4 387.2 1.05 ± 0.20
pnpr@HEAD 397.5 ± 36.8 344.5 459.2 1.24 ± 0.23
pnpr@main 321.3 ± 52.1 263.8 408.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.34565700046,
      "stddev": 0.020493307559215496,
      "median": 0.35048517296000004,
      "user": 0.37732047999999996,
      "system": 0.20132787999999996,
      "min": 0.31577086246,
      "max": 0.37254559446
    },
    {
      "command": "pacquet@main",
      "mean": 0.33629211596,
      "stddev": 0.03632660466699935,
      "median": 0.32678830046,
      "user": 0.36924908,
      "system": 0.20647278,
      "min": 0.29743521546,
      "max": 0.38718525046
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.39745871496,
      "stddev": 0.03675148048266508,
      "median": 0.39249932196000004,
      "user": 0.40750728,
      "system": 0.21927828,
      "min": 0.34447631946,
      "max": 0.45917199846
    },
    {
      "command": "pnpr@main",
      "mean": 0.32130944896,
      "stddev": 0.052099313136089315,
      "median": 0.31044567496000003,
      "user": 0.35286797999999997,
      "system": 0.19855657999999998,
      "min": 0.26379662046,
      "max": 0.40876862946000003
    }
  ]
}

@Newspicel
Newspicel marked this pull request as ready for review September 29, 2026 11:01
@Newspicel
Newspicel requested a review from zkochan as a code owner September 29, 2026 11:01
Copilot AI balanced review requested due to automatic review settings September 29, 2026 11:01
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 29, 2026
Copilot AI review requested due to automatic review settings September 29, 2026 12:51
@zkochan
zkochan force-pushed the fix/shim-helpers-without-default-path branch from 2f470c3 to 29cbda9 Compare September 29, 2026 12:52

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Shims miss available PATH helpers 🐞 Bug ≡ Correctness ⭐ New
Description
run_helper treats a successful command -p -v as proof that command -p can execute the helper,
although Bash 3.2 can answer that lookup from the filtered PATH. When its default path lacks a
helper that the filtered PATH contains, symlinked package shims and pnpm aliases select `command
-p` instead of the available helper and fail during startup.
Code

pnpm/crates/cmd-shim/src/shim/sh.rs[222]

+  if command -p -v "$1" >/dev/null 2>&1 || ! command -v "$1" >/dev/null 2>&1; then command -p "$@"; else command "$@"; fi
Relevance

●●● Strong

Exact Bash 3.2 PATH-selection bug fixes are accepted; closely matching shim fallback changes merged
recently.

PR-#14903

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The repository documents Bash 3.2's PATH-based command -p -v result, while the new conditional
uses that result to choose command -p. The changed test covers the opposite case—no helper on
caller PATH—so it does not exercise the failing selection. The same conditional is used by alias
symlink resolution.

pnpm/crates/cmd-shim/src/shim/tests.rs[1092-1120]
pnpm/crates/cmd-shim/src/shim/sh.rs[219-240]
pnpm/crates/cli/src/cli_args/setup.rs[258-288]

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

## Issue description
On Bash 3.2, `command -p -v` can find a helper in `PATH` even when `command -p` cannot execute it from the default path. The current selection then skips the available fallback.

## Fix Focus Areas
- pnpm/crates/cmd-shim/src/shim/sh.rs[219-223]
- pnpm/crates/cli/src/cli_args/setup.rs[258-262]
- pnpm11/bins/cmd-shim/src/index.ts[640-644]
- pnpm11/engine/pm/commands/src/setup/setup.ts[191-195]

## Recommended Fix
Use helper selection that does not infer `command -p` execution from `command -p -v` alone. Update every generated and checked-in launcher copy, and add a test for the case where the default path lacks a helper but the filtered caller `PATH` contains it.

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

Dismiss ↗ | View ↗


2. One changeset mixes both release lines 📘 Rule violation § Compliance
Description
The new changeset lists pnpm and pacquet alongside the affected v11 packages in one file, rather
than separating the v11 and v12 bumps. Because this PR changes both the TypeScript shims and the
Rust shims, a later release-note edit for one version would also apply to the other version's
changeset.
Code

.changeset/shim-helpers-without-default-path.md[R6-7]

+"pnpm": patch
+"pacquet": patch
Relevance

●●● Strong

Recent reviews consistently require separate v11/v12 changesets, including an exact same-day
precedent.

PR-#16381
PR-#16324
PR-#16221

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 713436 requires separate changeset files when one PR changes both the TypeScript v11 and Rust
v12 stacks. The single new file includes both pnpm and pacquet; the diff also changes their
respective shim implementations.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/shim-helpers-without-default-path.md[1-10]
pnpm11/bins/cmd-shim/src/index.ts[640-653]
pnpm/crates/cmd-shim/src/shim/sh.rs[219-232]

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 pnpm v11 and v12 package bumps even though the checklist requires separate files when both stacks change.

## Fix Focus Areas
- .changeset/shim-helpers-without-default-path.md[1-10]

## Recommended Fix
Create one changeset for the affected v11 packages, including `pnpm`, and a separate changeset for `pacquet`. Give each entry wording specific to its release line.

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

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 63 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/setup (sha: fbda4c85) — View relationship
  Explored: repo: pnpm/exec (sha: d9dca8d2) — View relationship
  Explored: repo: pnpm/get.pnpm.io (sha: 916ce9e8) — View relationship
Review mode: ⚖️ Balanced: This changes runtime shell helper resolution across several generated and source paths, affecting PATH behavior in restricted environments and warranting a careful security/correctness review, but the logic is repeated rather than independently bug-dense.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 768cb89

Results up to commit 29cbda9 ⚖️ Balanced


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


Remediation recommended
1. One changeset mixes both release lines 📘 Rule violation § Compliance
Description
The new changeset lists pnpm and pacquet alongside the affected v11 packages in one file, rather
than separating the v11 and v12 bumps. Because this PR changes both the TypeScript shims and the
Rust shims, a later release-note edit for one version would also apply to the other version's
changeset.
Code

.changeset/shim-helpers-without-default-path.md[R6-7]

+"pnpm": patch
+"pacquet": patch
Relevance

●●● Strong

Recent reviews consistently require separate v11/v12 changesets, including an exact same-day
precedent.

PR-#16381
PR-#16324
PR-#16221

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 713436 requires separate changeset files when one PR changes both the TypeScript v11 and Rust
v12 stacks. The single new file includes both pnpm and pacquet; the diff also changes their
respective shim implementations.

Rule 713436: Changesets for pnpm v11 vs v12 (pacquet) must target the correct package and bump type
.changeset/shim-helpers-without-default-path.md[1-10]
pnpm11/bins/cmd-shim/src/index.ts[640-653]
pnpm/crates/cmd-shim/src/shim/sh.rs[219-232]

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 pnpm v11 and v12 package bumps even though the checklist requires separate files when both stacks change.

## Fix Focus Areas
- .changeset/shim-helpers-without-default-path.md[1-10]

## Recommended Fix
Create one changeset for the affected v11 packages, including `pnpm`, and a separate changeset for `pacquet`. Give each entry wording specific to its release line.

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

Dismiss ↗ | View ↗


Grey Divider

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.

…PATH

The bash 3.2 that macOS ships as sh ignores -p for command -v, so
run_helper's probe searched the filtered caller PATH. A caller whose PATH
lacked /usr/bin then fell through to a plain `command readlink` that
found nothing, although `command -p readlink` would have worked. Take a
helper from PATH only when PATH actually has it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI review requested due to automatic review settings September 29, 2026 12: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

Code review by qodo was updated up to the latest commit 768cb89

@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 2b511eb into pnpm:main Sep 29, 2026
66 checks passed
@welcome

welcome Bot commented Sep 29, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@zkochan

zkochan commented Sep 29, 2026

Copy link
Copy Markdown
Member

Review-and-fix summary. The PR was merged at 768cb89 while this pass was wrapping up.

Fixed in 768cb89: the bash 3.2 that macOS ships as sh ignores -p in command -p -v and searches PATH (see builtins/command.def in bash 3.2.57, where describe_command gets no standard-path flag). With the first version of run_helper, a macOS caller whose PATH lacked /usr/bin fell through to a plain command readlink, which found nothing, although command -p readlink would have worked before this PR. run_helper now takes a helper from PATH only when PATH actually has it. New tests in both stacks emulate that bash by rewriting command -p -v to command -v and run the shim with a PATH that holds only node. Both tests fail against the unguarded helper and pass with the guard.

Validation: pnpm-cmd-shim plus the pnpm-cli setup/alias tests (261 passed), @pnpm/bins.cmd-shim node tests (82 passed), pnpm/npm/pnpm launcher tests (68 passed), the @pnpm/exe setup tests, the engine.pm.commands setup tests, and pre-push-rust.sh. CI was green on the head (65 pass, 1 skipped).

Review status: CodeRabbit reported no actionable comments on 768cb89. Copilot could not review because of quota. I declined Qodo's two findings on the head:

  • Shims miss available PATH helpers. This needs bash 3.2 as sh together with a default path that lacks readlink/sed/uname. macOS always has them in /usr/bin, and Nix sandboxes ship a modern bash, whose command -p -v honors -p. A fully general probe would cost an extra subshell per helper for a combination no supported host has.
  • One changeset mixes both release lines. AGENTS.md allows one changeset naming both the v11 packages and pacquet when the same release-note text applies to both, and it does here.

Nothing remains within scope.


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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POSIX bin shims fail in Nix builds: command -p sed not found

4 participants