Repository navigation
Run the pnpm of the hosted pnpm tests in the directory's own spelling on Windows - #2245
Conversation
On Windows the real-pnpm test `pnpm11_registry_route_is_cleaned_up_when_a_patch_is_not_needed` failed at its first case: after `pnpm remove peer-user` the lock still held the routed release of peer-user. pnpm had exited 0 and had not touched the root importer `.`; it had written the change under a second importer for the same project, `../../../../../../RUNNER~1/AppData/Local/Temp/<tmp>/removed-scan`. That key is the path from the lock's directory to the project's, so pnpm held two spellings of one directory. The suite starts pnpm in a directory under the temp directory, which a hosted Windows runner spells with an 8.3 short name (`C:\Users\RUNNER~1\AppData\Local\Temp`; the profile is `C:\Users\runneradmin`). pnpm 11 takes the project directory from its working directory through Node's JavaScript realpath, which keeps a short name, and searches the workspace root from the same directory through `fs.realpath.native`, which expands it. With a pnpm-workspace.yaml in the project (a routed scan creates one) the lock lives at the workspace root, and `pnpm remove`, `pnpm add` and `pnpm update` key the project by the path between the two spellings in place of `.`. `pnpm install` and `pnpm dedupe` take their projects from the workspace root, which is why the other tests of the target pass there: they run those, or run `pnpm add` and look only at `packages:` and the installed files. On Linux and macOS the working directory a process reads back is already resolved. pnpm 11.27.0 does the same on macOS when its workspace root is given through a symlinked spelling: `remove`, `add` and `update` add an importer `../../real/<project>` and leave `.` with the dependency that was removed; `install` and `dedupe` keep the single `.`. `corepack_command`, through which every pnpm of the suite starts, now sets the working directory to the canonical spelling without the verbatim prefix, the string pnpm computes for the workspace root. socket-patch still gets each directory as the test spelled it, so the suite keeps running the CLI on a short-name path. No assertion changes. The CLI is not changed: it never runs pnpm in a project, and it writes no file system path into pnpm-lock.yaml or pnpm-workspace.yaml. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Main brought the two changes that the Windows run of this branch still failed without: the rule that checks the pnpm registry fixtures out as committed, and the scan futures built off the stack. No conflict. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Only the hosted pnpm e2e suite started pnpm in the canonical spelling of its project directory. The other suites that run a real pnpm still handed it the directory as `tempfile` spells it, an 8.3 short name on a hosted Windows runner, so the next test there that runs `pnpm add`, `remove` or `update` on pnpm 11 would get a second importer in the lock again and have to be diagnosed again. `hermetic::start_in(cmd, dir)` in tests/common sets a package manager's working directory to `hermetic::os_spelling(dir)`. The pnpm launchers of e2e_redirect_pnpm_build, e2e_redirect_rush_sim (pnpm, and Rush in the opt-in leg), e2e_safety_pnpm (`common::pnpm_run`), e2e_vendor_pnpm_build and e2e_vendor_rush go through it. None of them chose its spelling on purpose: each passed a directory under its temp directory. socket-patch is still started in the directory as each test spells it. `os_spelling` is the one helper for "canonicalize, then drop the verbatim prefix": `member_root` of in_process_redirect_pnpm, `canonical` of the sbt drivers and `fixture_root` of the Gradle driver call it in place of their own copies. It panics with the path when the directory cannot be resolved. The first version fell back to the caller's spelling, which would have brought the failure back with no signal. `java_path` and `file_uri` of the sbt drivers keep their own strip: they take locations that need not exist and must not be resolved. The comment at the hosted suite's launcher said pnpm keeps the project directory as the process was given it. pnpm takes it from `fs.realpathSync(cwd)`, which resolves links and leaves an 8.3 name as spelled, so a symlinked directory does not diverge. The helper's doc says so, and the launcher states the invariant in two lines. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On Windows, pnpm 11 started from a directory spelled with an 8.3 short name, in a project that has a pnpm-workspace.yaml, records what `pnpm add`, `remove` and `update` change under a second `importers:` entry of the lock and leaves `.` as it was. Hosted mode creates that file for a pnpm 11 project that had none, so a user can reach this after a scan. It is pnpm's own behaviour and the CLI is not changed: it never runs pnpm in a project and writes no path into either file. docs/ecosystems.md now names the limit and the way out (run pnpm from the directory's long name) beside the rule for creating the file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryLow Risk Overview Adds No socket-patch product code changes. Reviewed by Cursor Bugbot for commit 573a638. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. Test-harness fix for #2235: every suite that runs a real pnpm (and the Rush launchers) now starts it in the directory's canonical spelling, so on a Windows runner whose temp dir is an 8.3 short name ( Risk: low. Tests and docs only; the CLI still gets each directory as the test spelled it, so short-name coverage of socket-patch itself is kept. No assertion is weakened or skipped. Look here
Verified. Read the whole diff. Changes I made. None. Open questions. None. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed the new os_spelling and start_in helpers and every launcher in the five suites. No pnpm, Rush or npm launcher was missed, and the socket-patch launchers keep the test's own spelling as described. No findings.
Tests and one docs sentence: the real-pnpm e2e suites now start pnpm in the canonical spelling of each project directory, which fixes
pnpm11_registry_route_is_cleaned_up_when_a_patch_is_not_neededon Windows; the CLI does not change, so there is nothing for the release notes.Fixes #2235
What failed
Job
e2e-windows (windows-latest, e2e_redirect_pnpm_build, ...): the test panics at its first case,removed-scan, on "pnpm dropped the release and still records its override". The lock it prints has two importers for one project:pnpm remove peer-userexited 0 and wrote its change under a new key. The root importer still asks forpeer-user, so the routed release stays inpackages:and the assertion fails. The test passes on Linux and macOS, and its pnpm 12 twin passes on the same runner.Why
The key is the path from the lock's directory to the project's: six levels up, then down again through
RUNNER~1. pnpm held two spellings of one directory. A hosted Windows runner has both: the profile isC:\Users\runneradmin, and%TEMP%, wheretempfile::tempdir()puts every project of the suite, isC:\Users\RUNNER~1\AppData\Local\Temp. The suite started pnpm with the project as its working directory, in that spelling.pnpm 11 (read in the 11.27.0 bundle):
fs.realpathSync(<working directory>), Node's JavaScript walk, which resolves links and keeps every other component as spelled, a short name included;fs.realpath.native(<working directory>), the operating system's answer, with long names. With apnpm-workspace.yamlin the project (a routed scan creates one) the lock lives at that root;pnpm removemutates the one project at the first spelling and keys itpath.relative(lockDir, projectDir) || '.'.pnpm addandpnpm updatefall into the same path when no workspace project equals the working directory.pnpm installandpnpm dedupetake their projects from the workspace root.Measured with pnpm 11.27.0 on macOS, the workspace root given through a symlinked spelling (
NPM_CONFIG_WORKSPACE_DIR, which pnpm takes as spelled):remove,addandupdateadd an importer../../real/<project>and leave.with the removed dependency, the shape of the CI lock;installanddedupekeep the single.; with one spelling all five keep..All 19 tests handed pnpm its directory the same way. This is the only one that runs
pnpm remove, and the only one that asserts on whatpnpm addof an existing dependency leaves in a project with a workspace file.What changes
hermetic::start_in(cmd, dir)intests/commonstarts a package manager inhermetic::os_spelling(dir):std::fs::canonicalizewithout the verbatim\\?\prefix, the string pnpm computes for the workspace root.e2e_redirect_pnpm_build,e2e_redirect_rush_sim,e2e_safety_pnpm,e2e_vendor_pnpm_build,e2e_vendor_rush.docs/ecosystems.mdrecords the limit below.The Windows run of the first commit (the hosted suite alone) passed the job:
pnpm11_registry_route_is_cleaned_up_when_a_patch_is_not_needed ... ok, 19 of 19.Were users on Windows affected
Not by socket-patch. It never runs pnpm in a project (its one pnpm call is
pnpm root -g, from the home directory, for global scans), and it writes no file system path:pnpm-workspace.yamlgetspackages: ['.'],trustLockfile, registry URLs and overrides; inpnpm-lock.yamlit editsoverrides:,packages:/snapshots:keys and the values of existing importers, and never adds or renames an importer.One limit stays reachable and is now in the docs: on Windows, in a project that has a
pnpm-workspace.yaml(hosted mode creates one for a pnpm 11 project that had none), pnpm 11 started from a directory spelled with an 8.3 short name records whatpnpm add,removeandupdatechange under a secondimporters:entry and leaves.as it was; that is pnpm's behaviour, and running pnpm from the directory's long name avoids it.Code review
No defect found in the first commit. Five points, all applied:
docs/ecosystems.mdbeside the rule for creatingpnpm-workspace.yaml, and the paragraph above. No product change, no new warning.os_spellingno longer falls back to the caller's spelling: a directory that cannot be resolved panics there, with its path.e2e_vendor_rushwas not named in the review and has the same Rush launcher). None of them chose its spelling on purpose. The launchers of socket-patch itself are left alone.member_root(in_process_redirect_pnpm),canonical(sbt drivers) andfixture_root(Gradle driver, a fourth copy) callos_spelling. Left:java_pathandfile_uriof the sbt drivers, which only drop the prefix, from locations that need not exist and must not be resolved.fs.realpathSyncdescribed as it is (links resolved, an 8.3 name kept).Checked
On macOS, at the head:
rustfmt --check --edition 2021on the changed files.cargo clippy --locked --workspace --all-features -- -D warnings.cargo check --locked --workspace --all-targets --all-features: every target builds. Two unused-import warnings, both in files this change does not touch.in_process_pnpm_registry_cleanup: 238 passed, none failed. That includesin_process_redirect_pnpm, two new self-tests of the launcher step, and the vendored suite's real pnpm 7, 8 and 10 lifecycles.pnpm_hostedand both golden suites: 72 passed.SOCKET_PATCH_PNPM_E2E_BIN): passed.Only a Windows run can confirm the rest:
e2e_safety_pnpm,e2e_redirect_rush_simande2e_vendor_rushnow run pnpm in the long spelling there while socket-patch keeps the short one. A test of those legs that fails where it passed before is this change.🤖 Generated with Claude Code