GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(arborist): skip extraneous fsChildren in linked-strategy reify by manzoorwanijk · Pull Request #9332 · npm/cli

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented May 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

In continuation of our exploration of using install-strategy=linked in the Gutenberg monorepo, which powers the WordPress Block Editor.

When using install-strategy=linked, removing a workspace from the project (deleting its directory and dropping its entry from the root package.json's workspaces array) does not actually clean it up: the next npm install re-creates the deleted directory as <wsdir>/node_modules/<name> -> .. — an empty directory shell with a self-loop symlink and no source files.
The hoisted (default) install strategy is unaffected: the directory stays gone.

The root cause is in IsolatedReifier#makeIdealGraph in workspaces/arborist/lib/arborist/isolated-reifier.js.
On every install, loadVirtual reads the previous lockfile and re-creates a node for every entry, including a link: true entry for a workspace that has just been removed from the manifest.
That node has no incoming workspace edge from the root, so calcDepFlags correctly marks it extraneous, but it still ends up in idealTree.fsChildren because its path is a descendant of the project root.
makeIdealGraph then iterated fsChildren blindly to populate idealGraph.workspaces, treating the orphan exactly like a real workspace.
createIsolatedTree materialised it as an IsolatedNode plus an IsolatedLink and, because the orphan is not in #rootDeclaredDeps, took the self-link branch — writing the workspace directory and the node_modules/<name> -> .. symlink back to disk.

Fixed by filtering out extraneous fsChildren before the sweep that populates idealGraph.workspaces.
A real workspace declared in package.json's workspaces array is reachable via a workspace-type edge from the root, so it is never extraneous.
A local file: dep target that legitimately lives inside the project tree is reachable via the Link in node_modules, so it is also never extraneous.
The only fsChildren entries that show up as extraneous are precisely the ghost workspaces left over in the lockfile after the user removed them — which is exactly what we want to skip.

The sibling queue walk (which seeds idealGraph.external from edgesOut) is intentionally left alone: the orphan has no edges out and no incoming references, so it falls through the isLocalFileDep / external branches harmlessly.
This keeps the change surgical to the one place where fsChildren is treated as the source of truth for "this is a workspace."

Companion to #9330 (lockfile prune): with the prune fix in place, the orphan no longer appears in package-lock.json's packages map; with this fix in place, the linked strategy no longer re-materialises the orphan on disk.
Either fix on its own is incomplete — the lockfile prune does not stop reify from re-creating the directory, and this fix does not stop the lockfile from carrying forward the entry.

The regression test seeds a project with two workspaces under install-strategy=linked, removes one workspace's directory and its entry from package.json, runs reify again, and asserts the directory stays gone.
The test fails before the fix (the directory and its self-loop symlink come back) and passes after.

References

Fixes #9331
Related to #9330, #5463

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@manzoorwanijk
fix(arborist): skip extraneous fsChildren in linked-strategy reify
409cb8d
@manzoorwanijk
manzoorwanijk requested review from a team as code owners May 8, 2026 18:51
owlstronaut
owlstronaut approved these changes May 11, 2026
View reviewed changes
@owlstronaut owlstronaut added the backport:v11 label May 11, 2026
@owlstronaut
owlstronaut merged commit 81793ae into npm:latest May 11, 2026
18 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request May 11, 2026
fix(arborist): skip extraneous fsChildren in linked-strategy reify #9340
Merged
@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🎉 Backport to release/v11 created: #9340

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request May 11, 2026
chore: release 12.0.0-pre.0.0 #9229
Merged
@manzoorwanijk
manzoorwanijk deleted the fix/linked-strategy-recreates-removed-workspace-dir branch May 12, 2026 10:13
@github-actions github-actions Bot mentioned this pull request May 27, 2026
chore: release 12.0.0-pre.1 #9387
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@owlstronaut owlstronaut owlstronaut approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backport:v11

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] install-strategy=linked re-creates a removed workspace's directory on npm install

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@manzoorwanijk @owlstronaut
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.