Skip to content

fix(arborist): derive linked bin cleanup paths through bin-links (v10 backport) - #10346

Open
jasperjjhe wants to merge 1 commit into
npm:release/v10from
jasperjjhe:fix/bin-cleanup-paths-v10
Open

jasperjjhe wants to merge 1 commit into
npm:release/v10from
jasperjjhe:fix/bin-cleanup-paths-v10

Conversation

@jasperjjhe

Copy link
Copy Markdown

Summary

Manual backport of #10057 to release/v10, as requested by the backport automation note on that PR (the cherry-pick to release/v10 conflicted; the v11 backport landed as #10266).

npm 10 bundles bin-links@5.0.1, which includes the bin metadata normalization from bin-links#193 (the v5 maintenance-line release of npm/bin-links#187). Node.binPaths already routes through bin-links#getPaths, so hoisted installs produce normalized bin paths. The linked install strategy's cleanup derivation in isolated-reifier still manually joins lockfile-provided bin keys, so traversal-bearing, absolute, or Windows-style bin keys in a lockfile can produce cleanup paths outside the package's node_modules/.bin when an optional dependency recorded in the lockfile fails to extract and reify cleans it up with scripts disabled. This routes that derivation through bin-links#getPaths() using the dependency's consumer-facing installation path, the same fix shape as #10057, so both strategies share the bundled normalization.

This is the Arborist integration for CLI-CROW-GEN-002 on the v10 line. It does not introduce an Arborist-owned normalizer or modify the bundled dependency.

Changes

  • Replace linked-mode manual bin path derivation with bin-links#getPaths() using the dependency's consumer-facing installation path, not its store path.
  • Add Node.binPaths regression coverage for traversal-bearing, absolute, Windows-style and invalid bin metadata, including preservation of the caller's metadata (adapted verbatim from fix(arborist): derive linked bin cleanup paths through bin-links #10057; v10's Node already uses getPaths and the bundled bin-links@5.0.1 provides the normalization).
  • Add hoisted and linked optional-extraction-failure regressions that verify an external sentinel survives cleanup with scripts disabled, plus a linked ideal-tree unit test asserting normalized bin paths (adapted from fix(arborist): derive linked bin cleanup paths through bin-links #10057 to the v10 test fixtures: the failure is triggered by the shared fixture server's built-in 404 paths (@isaacs/testing-missing-tgz tarball, @isaacs/this-does-not-exist-at-all packument) instead of the v12 registry-mock helper, and the lockfile resolved URLs point at the local mock registry).

Dependency status

No dependency changes. bin-links@5.0.1 (released 2026-10-26 via bin-links#193 with the getPaths normalization) is already pinned in the v10 lockfile, and no other v12-only change is required by the fix.

Notes

Validation

  • Patch applies cleanly to release/v10 at 3475294 (git apply --check verified against a pristine checkout).
  • Production change verified byte-identical to the merged fix(arborist): derive linked bin cleanup paths through bin-links #10057 fix.
  • The touched test suites were executed in a network-isolated Linux container (node:22-bookworm, deps from the lockfile via npm ci): tap test/arborist/reify.js test/node.js passes 107/107 and 56/56 including the adapted tests, and eslint on the three touched files is clean. Unpatched control at the same SHA also passes, so the adapted tests are the only delta.
  • One note for reviewers: v10's tnock fixture toggles nock's global net-connect state per test; the adapted tests deliberately avoid it and use the fixture server's built-in 404 paths instead, so the suite state machine is untouched.

@jasperjjhe
jasperjjhe requested a review from a team as a code owner November 25, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant