Skip to content

Fixes the pnpm linker crash on leftover workspace node_modules#305

Open
jeckhart wants to merge 2 commits into
yarnpkg:mainfrom
jeckhart:fix/pnpm-linker-leftover-workspace-dirs
Open

Fixes the pnpm linker crash on leftover workspace node_modules#305
jeckhart wants to merge 2 commits into
yarnpkg:mainfrom
jeckhart:fix/pnpm-linker-leftover-workspace-dirs

Conversation

@jeckhart

Copy link
Copy Markdown

Switching a monorepo from nodeLinker: node-modules to pnpm aborts:

➤ · I/O error (Operation not permitted (os error 1))

Repro (yarn 6.0.0-rc.18, bec529a):

# root package.json:   workspaces ["packages/*"], deps { no-deps: 1.0.0 }
# packages/pkg-a:       deps { no-deps: 2.0.0 }
yarn config set nodeLinker node-modules && yarn install
yarn config set nodeLinker pnpm && yarn install

The version conflict leaves no-deps@2.0.0 as a real directory at packages/pkg-a/node_modules/no-deps. The pnpm linker's symlink pass calls fs_rm_file (unlink) on that path, which fails on a directory — EPERM on macOS, EISDIR on Linux — and ok_missing only swallows NotFound. fs_remove_nm clears the root node_modules but never the per-workspace ones.

Fix: use the directory-aware fs_rm at the three symlink sites in link_project_pnpm. Adds a regression test that fails on current main and passes with the fix.

Closes #304

jeckhart added 2 commits May 30, 2026 01:56
The pnpm linker only wipes the root node_modules via fs_remove_nm, but
its symlink passes also write into <workspace>/node_modules/<dep> for
child workspaces. Switching from the node-modules linker can leave a
real directory at that path, and fs_rm_file (unlink) fails on a
directory (EPERM on macOS, EISDIR on Linux); ok_missing only swallows
NotFound, so install aborts with an I/O error.

Uses the directory-aware fs_rm at all three symlink sites.
@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

👷 Deploy request for yarn-v6 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d267886

@jeckhart

Copy link
Copy Markdown
Author

@arcanis - Sorry for the ping, I wasn't sure who to address this to from the project docs. I am using yarn 6 preview for some non-critical projects at work and I've found a few bugs. This was one that I thought I could help fix myself.

@arcanis

arcanis commented Jun 13, 2026

Copy link
Copy Markdown
Member

Hey John, apologies for the delay, I'll take a look tomorrow!

The main thing I want to check is whether we are truly replacing all previous node_modules, or just those that would happen to conflict with directory entries created by the pnpm linker (thus incorrectly leaving in place hoisted packages).

I somewhat suspect the pnpm linker should use the same fs_sync method as the NM linker rather than a direct fs_rm, to avoid that.

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.

pnpm linker crashes on leftover workspace node_modules when switching from node-modules

2 participants