Skip to content

fix(cmd-shim): handle unicode paths on windows - #16205

Merged
zkochan merged 2 commits into
pnpm:mainfrom
Xzese:fix/cmd-shim-unicode-6999
Sep 26, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
Xzese:fix/cmd-shim-unicode-6999

Conversation

@Xzese

@Xzese Xzese commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Windows CMD launchers are written as UTF-8, but CMD decodes them using the active console code page. A relative target such as 工具/cli.js is corrupted under legacy code pages, causing the installed tool to fail with MODULE_NOT_FOUND.

Both CMD generators now switch to UTF-8 when their generated text contains non-ASCII characters. They restore the caller's code page and preserve the tool's exit status. ASCII-only launcher output is unchanged. The patch is limited to these generators, matching regression tests, and a changeset; it adds no dependencies.

close #6999

Squash Commit Body

Decode non-ASCII CMD launcher text using UTF-8 in both implementations.
Relative paths can still contain Unicode, so using the shim directory as
the base does not eliminate the encoding failure.

Record the current code page before reading Unicode literals, restore it
after the tool finishes, and return its exit status. Clear the reserved
ERRORLEVEL environment override within SETLOCAL before invoking the tool
so it cannot shadow the actual exit status. Resolve chcp.com through its
system path rather than the package-controlled PATH.

Leave ASCII-only CMD output unchanged. Add execution regressions under
code pages 437, 936 and 65001 for argument forwarding, exit codes 0 and 7,
code-page restoration, and an inherited ERRORLEVEL override.
Also check that a Unicode NODE_PATH triggers the encoding switch before
its assignment, retains percent escaping, and preserves CRLF output.

Closes pnpm/pnpm#6999

Validation

  • Confirmed the regressions fail on the unfixed source in both stacks. UTF-8 controls pass.
  • pnpm --filter @pnpm/bins.cmd-shim test: 82 passed.
  • pnpm test:rust -p pnpm-cmd-shim: 127 passed, 5 platform-specific tests skipped on Windows.
  • A portable regression covers an ASCII target with a Unicode NODE_PATH; it fails on the unfixed generator and runs in the Linux coverage job.
  • Repository TypeScript lint, Rust workspace check/Clippy, spelling, and Rust/TOML formatting checks passed.
  • Strict dylint passes for pnpm-cmd-shim, including its tests.
  • Full Rust documentation passed with RUSTDOCFLAGS=-D warnings.
  • Rebuilt the TypeScript CLI and replayed the exact reproduction from the issue report: CP 437, 936 and 65001 all pass.
  • Tested on Windows 11 x64. A Chinese Windows account was not required; the regression uses a Unicode bin target beneath an ASCII temporary home.

The Windows pre-push strict dylint check fails in the unchanged pnpm-executor function short_path (pnpm/crates/executor/src/script_working_dir.rs:85): 43 lines exceed its limit of 40. I reproduced the failure separately and verified this file is byte-for-byte identical to current main. No unrelated executor changes are included. The CI dylint job runs on Linux, where this Windows-only function is excluded. After completing all checks and recording this failure, I published with git push --no-verify, the exception explicitly offered by pnpm/scripts/pre-push-rust.sh. Commit hooks ran normally.

Checklist

  • I checked the referenced issue and verified that none of the PRs already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes are implemented in every affected version.
  • Added a changeset if this PR changes any published package. It targets both CLI implementations and the published CMD shim package.
  • Added or updated tests.

Written by an agent (Codex, GPT-6). This PR was written with the help of an AI agent.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue that could prevent Windows command shims from running tools when their paths contain non-ASCII characters. Shims now handle Unicode paths across different Windows code pages while preserving the tool’s arguments, exit status, and the original code page.

Decode non-ASCII CMD launcher text using UTF-8 in both implementations.
Restore the caller's code page and return the tool's actual exit status.
Leave ASCII-only launcher output unchanged.

Add execution regressions under code pages 437, 936 and 65001, including
argument forwarding, failure status, and inherited ERRORLEVEL overrides.

Closes pnpm#6999
@welcome

welcome Bot commented Sep 26, 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 26, 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: 91e6d988-d88e-42ac-abed-f5bdb58bdae5

📥 Commits

Reviewing files that changed from the base of the PR and between a8994c6 and e37af2c.

📒 Files selected for processing (6)
  • .changeset/fix-unicode-cmd-shims.md
  • pnpm/crates/cmd-shim/src/shim.rs
  • pnpm/crates/cmd-shim/src/shim/tests.rs
  • pnpm/crates/cmd-shim/src/shim/tests/cmd_encoding.rs
  • pnpm11/bins/cmd-shim/src/index.ts
  • pnpm11/bins/cmd-shim/test/e2e.test.js

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


📝 Walkthrough

Walkthrough

The Rust and TypeScript command-shim generators now wrap scripts containing non-ASCII characters with UTF-8 code-page handling. Tests cover generated scripts and Windows execution under several code pages.

Changes

Unicode Windows command shims

Layer / File(s) Summary
Wrap non-ASCII shim scripts
pnpm/crates/cmd-shim/src/shim.rs, pnpm11/bins/cmd-shim/src/index.ts, .changeset/fix-unicode-cmd-shims.md
Both generators wrap non-ASCII scripts to switch to code page 65001, restore the previous code page when available, and preserve the command exit code. The changeset records patch releases.
Validate generated and executed shims
pnpm/crates/cmd-shim/src/shim/tests.rs, pnpm/crates/cmd-shim/src/shim/tests/cmd_encoding.rs, pnpm11/bins/cmd-shim/test/e2e.test.js
Tests check generated script content and Windows execution across code pages 437, 936, and 65001. They verify argument forwarding, code-page restoration, and exit status, including when ERRORLEVEL is set in the environment.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
[ #6999 ] Run commands from paths containing Chinese characters on Windows by using UTF-8 code-page handling. ✅

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

Merge Risk: ⚪ Minimal · up to e37af

No actionable merge-blocking issue remains; batch targets return to the shim so it can restore the code page.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e37af

The launchers restore the previous encoding and preserve the tool’s exit status during normal execution. If a launcher is interrupted, however, it can leave the console using a different encoding. No privilege-boundary expansion has been established.

Retained concerns

  • Low · reliability · inferred: An interrupted Unicode launcher can bypass code-page restoration and leave the shared console encoding changed for subsequent commands.
Security review details

Security Blast Radius

  • inferred — The new executable invocation and code-page mutation occur only for generated CMD text containing non-ASCII characters. The identified state exposure is the console used to execute such a launcher; wider shared-console use is not established.

Trust Boundaries and Controls

  • observed — Generated target paths and NODE_PATH can make the output Unicode, but do not select the chcp.com path; the helper uses SystemRoot\System32 and clears ERRORLEVEL within SETLOCAL.

Resilience and Maintainability Implications

  • inferred — Successful sequential calls can restore their captured code page, but the suffix-based cleanup does not cover interruption. Concurrent launchers sharing one console could also overwrite one another’s temporary code-page state; supported concurrent use is unknown.

Hardening Proposals

  • proposed — If privileged callers can execute these launchers with externally supplied environment variables, establish a trusted source for SystemRoot before relying on it to locate chcp.com.
✨ 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).


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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.04%. Comparing base (a8994c6) to head (e37af2c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16205      +/-   ##
==========================================
+ Coverage   92.03%   92.04%   +0.01%     
==========================================
  Files        1484     1484              
  Lines      199999   200016      +17     
==========================================
+ Hits       184070   184108      +38     
+ Misses      15929    15908      -21     

☔ 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 26, 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 2391.48 ms 2454.89 ms 2.7% 119.57 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1418.74 ms 1459.97 ms 2.9% 70.94 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 231.94 ms 227.05 ms -2.1% 11.60 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 248.27 ms 236.92 ms -4.6% 12.41 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 10.11 ms 10.20 ms 0.9% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 15.43 ms 9.86 ms -36.1% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 8.98 ms 9.51 ms 5.9% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 9.73 ms 9.64 ms -1.0% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2530.23 ms 2548.05 ms 0.7% 126.51 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1442.21 ms 1505.04 ms 4.4% 72.11 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 452.79 ms 499.57 ms 10.3% 22.64 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 279.64 ms 296.98 ms 6.2% 13.98 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-hot-store pacquet 1621.08 ms 1622.53 ms 0.1% 81.05 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 294.91 ms 278.73 ms -5.5% 14.75 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 204.96 ms 199.28 ms -2.8% 10.25 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 91.71 ms 91.64 ms -0.1% 4.59 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 634.51 ms 883.37 ms 39.2% 31.73 ms Inconclusive (overlapping samples)
isolated-linked-workspace-resolve-hot-cache-offline pacquet 223.68 ms 330.42 ms 47.7% 11.18 ms Inconclusive (not reproduced)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4460.53 ms 4569.10 ms 2.4% 223.03 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3485.40 ms 3481.34 ms -0.1% 174.27 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 144.27 ms 150.71 ms 4.5% 7.21 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 150.98 ms 159.17 ms 5.4% 7.55 ms Inconclusive (overlapping samples)

Integrated-Benchmark Report (Linux)

Commit: e37af2cc6cb2

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.478 ± 0.131 2.340 2.682 1.71 ± 0.16
pacquet@main 2.446 ± 0.123 2.339 2.675 1.68 ± 0.16
pnpr@HEAD 1.481 ± 0.131 1.345 1.700 1.02 ± 0.12
pnpr@main 1.453 ± 0.116 1.349 1.699 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4781751244400003,
      "stddev": 0.13078060393845423,
      "median": 2.4548922615400004,
      "user": 1.6506414800000002,
      "system": 1.83659574,
      "min": 2.3396900895400004,
      "max": 2.6815580965400003
    },
    {
      "command": "pacquet@main",
      "mean": 2.44606733214,
      "stddev": 0.12312314529703412,
      "median": 2.39148204304,
      "user": 1.5833659800000002,
      "system": 1.83838634,
      "min": 2.3390532415400003,
      "max": 2.6749210155400003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.48128577764,
      "stddev": 0.1309365233752559,
      "median": 1.45996873504,
      "user": 1.48074008,
      "system": 1.6035849399999997,
      "min": 1.34470822054,
      "max": 1.70026595654
    },
    {
      "command": "pnpr@main",
      "mean": 1.4529986426399997,
      "stddev": 0.11580924873959408,
      "median": 1.4187441390399997,
      "user": 1.4904070800000002,
      "system": 1.6008623399999997,
      "min": 1.34878697054,
      "max": 1.69943922454
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 237.4 ± 32.3 204.1 309.4 1.03 ± 0.15
pacquet@main 230.7 ± 10.5 218.0 250.6 1.00
pnpr@HEAD 238.2 ± 15.9 216.6 265.0 1.03 ± 0.08
pnpr@main 248.5 ± 12.6 225.4 268.5 1.08 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.23739233458000006,
      "stddev": 0.03232573118968215,
      "median": 0.22705236178000002,
      "user": 0.27408788,
      "system": 0.55076112,
      "min": 0.20412373728000002,
      "max": 0.30942871128000005
    },
    {
      "command": "pacquet@main",
      "mean": 0.23067780287999998,
      "stddev": 0.010511795193079909,
      "median": 0.23193595678,
      "user": 0.24723187999999996,
      "system": 0.57930562,
      "min": 0.21801041528,
      "max": 0.25058202528
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2382212470800001,
      "stddev": 0.01586624816448822,
      "median": 0.23692352628000002,
      "user": 0.25720448,
      "system": 0.53757322,
      "min": 0.21656601428000002,
      "max": 0.26495591828000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.24850636988000002,
      "stddev": 0.012581232625148443,
      "median": 0.24826520628000004,
      "user": 0.28113768,
      "system": 0.55456692,
      "min": 0.22538688128,
      "max": 0.26854595528
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.3 ± 1.0 8.5 13.9 1.04 ± 0.13
pacquet@main 10.2 ± 0.9 8.0 13.8 1.03 ± 0.12
pnpr@HEAD 10.0 ± 0.8 8.6 12.7 1.00
pnpr@main 15.3 ± 3.4 9.1 25.4 1.54 ± 0.36
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.010322452051182792,
      "stddev": 0.0009859609846067411,
      "median": 0.01019890532,
      "user": 0.005254597275985662,
      "system": 0.005773128888888884,
      "min": 0.00845049332,
      "max": 0.01393595932
    },
    {
      "command": "pacquet@main",
      "mean": 0.010218207008259103,
      "stddev": 0.0009288320173515519,
      "median": 0.01011282732,
      "user": 0.005538776761133601,
      "system": 0.005369586234817815,
      "min": 0.00802380532,
      "max": 0.01376158932
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009950727795655435,
      "stddev": 0.0007608493428307323,
      "median": 0.00985930732,
      "user": 0.005067024194756554,
      "system": 0.005569144868913854,
      "min": 0.00855520332,
      "max": 0.01270028532
    },
    {
      "command": "pnpr@main",
      "mean": 0.015323632696425863,
      "stddev": 0.0033976923051116,
      "median": 0.01543311032,
      "user": 0.008495049201520909,
      "system": 0.007707940684410644,
      "min": 0.00914671932,
      "max": 0.025426974320000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.3 ± 4.6 7.8 28.0 1.26 ± 0.52
pacquet@main 9.0 ± 0.7 7.5 10.6 1.00
pnpr@HEAD 9.6 ± 0.8 7.8 12.4 1.08 ± 0.12
pnpr@main 9.8 ± 0.6 8.5 12.8 1.09 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.011266828846796117,
      "stddev": 0.004589200388788242,
      "median": 0.00950951874,
      "user": 0.006282225242718449,
      "system": 0.005806689320388344,
      "min": 0.00783115174,
      "max": 0.027998136740000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.008953656541687768,
      "stddev": 0.0007421408566724426,
      "median": 0.00897597974,
      "user": 0.004894178902953586,
      "system": 0.004781493670886079,
      "min": 0.00754719374,
      "max": 0.010648034740000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.00964844464295359,
      "stddev": 0.0007664559471241281,
      "median": 0.009636677740000002,
      "user": 0.0053142810126582275,
      "system": 0.00505540928270042,
      "min": 0.007843491740000002,
      "max": 0.012360009740000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.009799707641287552,
      "stddev": 0.0006273455783061785,
      "median": 0.009734347740000001,
      "user": 0.005573406008583688,
      "system": 0.004931542918454937,
      "min": 0.008540560740000001,
      "max": 0.01283939874
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.544 ± 0.038 2.474 2.590 1.69 ± 0.15
pacquet@main 2.540 ± 0.026 2.516 2.585 1.69 ± 0.15
pnpr@HEAD 1.555 ± 0.132 1.411 1.754 1.03 ± 0.13
pnpr@main 1.508 ± 0.130 1.387 1.720 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5440343631399998,
      "stddev": 0.037501689420676346,
      "median": 2.5480455062400003,
      "user": 1.9180259800000001,
      "system": 1.55066688,
      "min": 2.47441175824,
      "max": 2.58996905324
    },
    {
      "command": "pacquet@main",
      "mean": 2.54045971174,
      "stddev": 0.025526981104387406,
      "median": 2.5302320917400003,
      "user": 1.9528166800000002,
      "system": 1.5852533799999997,
      "min": 2.5159633342400003,
      "max": 2.58465360224
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.55519434014,
      "stddev": 0.1320417605847444,
      "median": 1.5050427827400001,
      "user": 1.18025008,
      "system": 1.23378248,
      "min": 1.41062065524,
      "max": 1.75400187924
    },
    {
      "command": "pnpr@main",
      "mean": 1.5075149626400002,
      "stddev": 0.13046722405983538,
      "median": 1.44221352424,
      "user": 1.13632328,
      "system": 1.15850088,
      "min": 1.38737756624,
      "max": 1.72002055424
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 500.8 ± 25.6 459.3 540.9 1.70 ± 0.13
pacquet@main 463.3 ± 30.1 429.3 519.9 1.58 ± 0.13
pnpr@HEAD 293.8 ± 16.2 263.1 322.3 1.00
pnpr@main 294.8 ± 29.2 264.4 353.1 1.00 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.50083639374,
      "stddev": 0.025626789567056097,
      "median": 0.49957439534000003,
      "user": 0.6744830599999998,
      "system": 0.77512306,
      "min": 0.45928866784,
      "max": 0.5408742788400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.46331124203999996,
      "stddev": 0.03007058239662229,
      "median": 0.45279071884,
      "user": 0.6539168599999999,
      "system": 0.7090813600000001,
      "min": 0.42933177384,
      "max": 0.5198699228400001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29376001643999994,
      "stddev": 0.01624721023449311,
      "median": 0.29698049033999996,
      "user": 0.24142086000000001,
      "system": 0.57511756,
      "min": 0.26313184684,
      "max": 0.32225606384
    },
    {
      "command": "pnpr@main",
      "mean": 0.29477293374,
      "stddev": 0.02921498377477965,
      "median": 0.27963519284000005,
      "user": 0.24660696,
      "system": 0.5464662600000001,
      "min": 0.26442858184,
      "max": 0.35308252184
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.636 ± 0.040 1.597 1.719 5.80 ± 0.25
pacquet@main 1.634 ± 0.037 1.598 1.723 5.80 ± 0.24
pnpr@HEAD 0.282 ± 0.010 0.271 0.300 1.00
pnpr@main 0.310 ± 0.033 0.276 0.384 1.10 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.6363769377400001,
      "stddev": 0.03988259784589322,
      "median": 1.62253020774,
      "user": 0.87430568,
      "system": 0.8045715799999998,
      "min": 1.59736053524,
      "max": 1.71925516424
    },
    {
      "command": "pacquet@main",
      "mean": 1.6340292780399999,
      "stddev": 0.037175588327080754,
      "median": 1.62108018824,
      "user": 0.9319438799999998,
      "system": 0.82089038,
      "min": 1.59777539624,
      "max": 1.72335686624
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28191932434,
      "stddev": 0.009918214855228681,
      "median": 0.27872630374,
      "user": 0.24446868,
      "system": 0.52498708,
      "min": 0.27089322324000004,
      "max": 0.29994809024
    },
    {
      "command": "pnpr@main",
      "mean": 0.30987253344,
      "stddev": 0.03270802196201745,
      "median": 0.29490584374000006,
      "user": 0.26391178000000004,
      "system": 0.60256848,
      "min": 0.27593491924,
      "max": 0.38376609624
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 201.8 ± 10.8 186.0 219.4 2.20 ± 0.13
pacquet@main 208.7 ± 12.9 186.6 232.7 2.28 ± 0.15
pnpr@HEAD 91.5 ± 1.9 88.0 96.8 1.00
pnpr@main 92.1 ± 4.6 86.8 105.9 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.20181637188000004,
      "stddev": 0.010836367374522735,
      "median": 0.19927605208000002,
      "user": 0.20649991333333334,
      "system": 0.06962106,
      "min": 0.18603533608,
      "max": 0.21936189108
    },
    {
      "command": "pacquet@main",
      "mean": 0.20866496258000003,
      "stddev": 0.01285220767188271,
      "median": 0.20496127808,
      "user": 0.21946836333333333,
      "system": 0.06574597666666666,
      "min": 0.18660797308000002,
      "max": 0.23274881308
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09154679537032259,
      "stddev": 0.0019410950306655126,
      "median": 0.09164238708,
      "user": 0.03334229612903226,
      "system": 0.014073185161290322,
      "min": 0.08796142508,
      "max": 0.09680248908
    },
    {
      "command": "pnpr@main",
      "mean": 0.09209532692375001,
      "stddev": 0.0046096362029495516,
      "median": 0.09171457258,
      "user": 0.03239362375,
      "system": 0.014071966249999996,
      "min": 0.08677053608,
      "max": 0.10589296208
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 880.2 ± 261.8 533.0 1231.9 1.33 ± 0.46
pacquet@main 661.5 ± 121.3 422.3 835.1 1.00
pnpm@HEAD 3025.1 ± 283.0 2789.8 3625.3 4.57 ± 0.94
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.8802180266200001,
      "stddev": 0.2618363404020793,
      "median": 0.88336584862,
      "user": 0.9079872733333334,
      "system": 0.16910947333333332,
      "min": 0.53304472062,
      "max": 1.2318945426199999
    },
    {
      "command": "pacquet@main",
      "mean": 0.6615334833977778,
      "stddev": 0.12129137935395277,
      "median": 0.63451130862,
      "user": 0.6760294955555556,
      "system": 0.16823947333333333,
      "min": 0.42232463062000003,
      "max": 0.83508489362
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0250544286200003,
      "stddev": 0.28298266418491685,
      "median": 2.87966646562,
      "user": 4.661223162222222,
      "system": 0.22588036222222221,
      "min": 2.7897881356200003,
      "max": 3.6252851066200003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 328.8 ± 19.6 292.5 352.6 1.45 ± 0.16
pacquet@main 226.9 ± 20.8 203.9 276.6 1.00

Confirmation (reversed target order)

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@main 215.0 ± 10.5 203.0 239.6 1.01 ± 0.06
pacquet@HEAD 213.5 ± 6.5 202.3 222.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.32876524154000003,
      "stddev": 0.01957509092474283,
      "median": 0.33041616494000003,
      "user": 0.2634423,
      "system": 0.12786483999999995,
      "min": 0.29250755794,
      "max": 0.35261057594
    },
    {
      "command": "pacquet@main",
      "mean": 0.2269472151542857,
      "stddev": 0.0207539540644709,
      "median": 0.22368196544000002,
      "user": 0.1821666714285714,
      "system": 0.08634212571428569,
      "min": 0.20393897194000002,
      "max": 0.27655424394
    }
  ],
  "confirmation": {
    "results": [
      {
        "command": "pacquet@main",
        "mean": 0.2150352901923077,
        "stddev": 0.0105221069636107,
        "median": 0.2142312995,
        "user": 0.16934334769230766,
        "system": 0.0881388323076923,
        "min": 0.2029897815,
        "max": 0.2395771475
      },
      {
        "command": "pacquet@HEAD",
        "mean": 0.2134777245,
        "stddev": 0.0065415065591330245,
        "median": 0.2134377415,
        "user": 0.1689716553846154,
        "system": 0.08737621692307693,
        "min": 0.2022953435,
        "max": 0.2221886965
      }
    ]
  }
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.602 ± 0.195 4.408 4.871 1.31 ± 0.06
pacquet@main 4.528 ± 0.135 4.405 4.788 1.29 ± 0.05
pnpr@HEAD 3.536 ± 0.154 3.417 3.831 1.01 ± 0.05
pnpr@main 3.509 ± 0.076 3.410 3.628 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.601765757120001,
      "stddev": 0.19535282171978058,
      "median": 4.56909500212,
      "user": 1.85455176,
      "system": 2.02422474,
      "min": 4.40847049262,
      "max": 4.87096657062
    },
    {
      "command": "pacquet@main",
      "mean": 4.52818976332,
      "stddev": 0.13478890695533716,
      "median": 4.460532605120001,
      "user": 1.77459906,
      "system": 2.0090266399999996,
      "min": 4.40468071262,
      "max": 4.787714089620001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5356753774199996,
      "stddev": 0.15414343247003273,
      "median": 3.48134298262,
      "user": 1.64096486,
      "system": 1.7834989399999999,
      "min": 3.4172875566200003,
      "max": 3.83121722962
    },
    {
      "command": "pnpr@main",
      "mean": 3.5085594267199993,
      "stddev": 0.07577601185118774,
      "median": 3.48540417462,
      "user": 1.62232186,
      "system": 1.8021042399999998,
      "min": 3.41022251562,
      "max": 3.6276916326200004
    }
  ]
}

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 152.2 ± 6.8 142.8 166.8 1.05 ± 0.08
pacquet@main 145.5 ± 8.8 124.1 162.7 1.00
pnpr@HEAD 160.1 ± 9.2 148.0 179.2 1.10 ± 0.09
pnpr@main 148.0 ± 11.1 129.0 167.4 1.02 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.15222822248222226,
      "stddev": 0.006845121488098054,
      "median": 0.15070536276000002,
      "user": 0.18632797555555555,
      "system": 0.16588645333333332,
      "min": 0.14277935576,
      "max": 0.16680887876
    },
    {
      "command": "pacquet@main",
      "mean": 0.1454944611975,
      "stddev": 0.008800009602329616,
      "median": 0.14427235226000001,
      "user": 0.18378210749999999,
      "system": 0.14240261999999998,
      "min": 0.12409281376,
      "max": 0.16271074076
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.1601005196975,
      "stddev": 0.009187591875389178,
      "median": 0.15916904626,
      "user": 0.1904773575,
      "system": 0.14696718250000002,
      "min": 0.14796871076,
      "max": 0.17915967776
    },
    {
      "command": "pnpr@main",
      "mean": 0.1480236719364706,
      "stddev": 0.011056838603571335,
      "median": 0.15098329476,
      "user": 0.1737948905882353,
      "system": 0.14162206117647058,
      "min": 0.12900057276000002,
      "max": 0.16737225976
    }
  ]
}

Check an ASCII target with a Unicode NODE_PATH so Linux coverage exercises
the encoding switch. Verify ordering, percent escaping, and CRLF output.
@Xzese
Xzese marked this pull request as ready for review September 26, 2026 17:04
@Xzese
Xzese requested a review from zkochan as a code owner September 26, 2026 17:04
@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 →

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 26, 2026
@Xzese Xzese mentioned this pull request Sep 26, 2026
2 of 4 tasks
@zkochan
zkochan merged commit 79e7bf5 into pnpm:main Sep 26, 2026
65 checks passed
@balwahidi

Copy link
Copy Markdown
Contributor

The .ps1 shims have the same problem under Windows PowerShell 5.1, which decodes a script without a byte order mark using the ANSI code page. Reported in #16217, with a fix in #16221 that writes non-ASCII .ps1 shims with a UTF-8 BOM in both implementations.


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

zkochan pushed a commit to balwahidi/pnpm that referenced this pull request Sep 27, 2026
Windows PowerShell 5.1 decodes a script that has no byte order mark
using the ANSI code page, so non-ASCII text in a PowerShell shim, such as
a bin path under a directory named 工具, reaches Node.js corrupted and
the command fails with MODULE_NOT_FOUND. PowerShell 7 reads such scripts
as UTF-8, so only Windows PowerShell 5.1 is affected.

Start the .ps1 text with a UTF-8 BOM when it contains non-ASCII
characters, in both the Rust and the TypeScript generators, the way
pnpm#16205 switches .cmd shims to UTF-8. ASCII-only shims stay
byte-for-byte unchanged. The Rust generator runs only on Windows, and the
TypeScript one adds the BOM only there, because on other platforms the
shebang has to stay at the start of the file.

Add regressions that run a shim for a Unicode target under Windows
PowerShell 5.1 and check its arguments and exit status, and check that
only non-ASCII shims get the BOM.

Closes pnpm#16217

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zkochan added a commit that referenced this pull request Sep 27, 2026
)

Windows PowerShell 5.1 decodes a script that has no byte order mark
using the ANSI code page, so non-ASCII text in a PowerShell shim, such as
a bin path under a directory named 工具, reaches Node.js corrupted and
the command fails with MODULE_NOT_FOUND. PowerShell 7 reads such scripts
as UTF-8, so only Windows PowerShell 5.1 is affected.

Start the .ps1 text with a UTF-8 BOM when it contains non-ASCII
characters, in both the Rust and the TypeScript generators, the way
#16205 switches .cmd shims to UTF-8. ASCII-only shims stay
byte-for-byte unchanged. Both generators add the BOM only on Windows,
because on other platforms the shebang has to stay at the start of the
file.

Add regressions that run a shim for a Unicode target under Windows
PowerShell 5.1 and check its arguments and exit status, check that
only non-ASCII shims get the BOM, and check that a non-ASCII shim
written on POSIX keeps its shebang at the start.

Closes #16217

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Zoltan Kochan <[email protected]>
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.

Chinese path problem

4 participants