Skip to content

fix(arborist): derive linked bin cleanup paths through bin-links - #10057

Open
martinrrm wants to merge 4 commits into
latestfrom
fix/arborist-bin-paths
Open

martinrrm wants to merge 4 commits into
latestfrom
fix/arborist-bin-paths

Conversation

@martinrrm

@martinrrm martinrrm commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Route linked-install bin cleanup paths through bin-links#getPaths() instead of manually joining lockfile-provided bin keys. Regular Node.binPaths already uses this API, so both strategies can share the defensive bin normalization introduced by npm/bin-links#187.

This is the Arborist integration for CLI-CROW-GEN-002. 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.
  • Add hoisted and linked optional-extraction-failure regressions that verify an external sentinel survives cleanup with scripts disabled.

Dependency status

npm CLI now bundles released bin-links@7.0.1 through #10152. This branch is rebased onto latest and uses that released normalization. A corresponding release/v11 backport is still needed.

Validation

  • Focused and full @npmcli/arborist tests, eslint, and template-oss postlint pass locally on Node 24.15.0.
  • Mutation testing confirms the direct isolated-tree regression fails when the production getPaths() integration is removed.
  • The npm/cli CI matrix passes on Linux, macOS, and Windows across all configured Node versions.
  • No dependency installs, lockfile changes, snapshots, generated files, or CI changes.

martinrrm and others added 2 commits October 28, 2026 01:25
Use the same bin path derivation for regular and linked installs so both consume the defensive normalization from npm/bin-links#187. Add traversal and optional-cleanup regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a direct isolated-tree assertion so the regression fails when linked bin cleanup paths bypass bin-links normalization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3e53db77-0fe4-4320-8ada-f2962ddd303c
@martinrrm
martinrrm force-pushed the fix/arborist-bin-paths branch from b6edc9a to aa3bb20 Compare October 28, 2026 01:42
Look up the isolated linked dependency using path.join so the regression runs on Windows as well as POSIX.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3e53db77-0fe4-4320-8ada-f2962ddd303c
@martinrrm
martinrrm marked this pull request as ready for review October 28, 2026 01:53
@martinrrm
martinrrm requested a review from a team as a code owner October 28, 2026 01:53
jeffkl
jeffkl previously approved these changes Oct 28, 2026
nkolev92
nkolev92 previously approved these changes Oct 28, 2026
@nkolev92

Copy link
Copy Markdown
Contributor

A corresponding release/v11 backport is still needed.

Wouldn't a simple backport via the label work for this one?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The linked-mode test can pass without exercising optional-failure cleanup because its invalid digest does not force extraction to fail; it needs an independent tarball failure and an assertion that the optional dependency is absent.

1 open issue
What changed in this PR

This PR routes Arborist’s linked-install bin cleanup through bin-links#getPaths(), sharing the defensive normalization already used by regular installs.

Changes:

  • Derive linked bin cleanup paths from consumer-facing installation paths.
  • Add coverage for unsafe and invalid bin metadata without mutating caller data.
  • Add optional-extraction-failure sentinel tests and a direct linked-tree normalization regression.
File Description
workspaces/​arborist/​test/​node.js Tests bin normalization and metadata preservation.
workspaces/​arborist/​test/​arborist/​reify.js Adds cleanup-safety and linked-tree regression tests.
workspaces/​arborist/​lib/​arborist/​isolated-reifier.js Replaces manual bin path construction with getPaths().

Review effort: Balanced

Mock a missing tarball independently of integrity so both hoisted and linked installs exercise optional-dependency cleanup. Assert that the failed dependency is absent before checking the external sentinel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: eac8b072-e785-47d5-ba34-9a7b20684ae0
@martinrrm
martinrrm dismissed stale reviews from nkolev92 and jeffkl via c60478d November 2, 2026 22:19
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.

4 participants