#7264·berry

[Bug?]: yarn run may fail on missing unrelated dependencies with pnp linker

Author: cdcxdCreated Aug 22, 2026Updated Aug 22, 2026
Labelsbug

Self-service

  • I'd be willing to implement a fix

Describe the bug

The issue was yarn run / yarn bin / yarn node under pnp linker would resolve every packages without a valid install-state.gz . If the pnp map covers what it needs, but not all packages, it will throw. The message is usually couldn't find an unrelated package.

Why I think it's a fix

To reproduce

Minimal Reproduce

.gitignore

# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

package.json

json
{
  "name": "reproduce",
  "version": "1.0.0",
  "scripts": {
    "start": "next start"
  },
  "dependencies": {
    "next": "14.2.15",
    "react": "18.3.1",
    "react-dom": "18.3.1"
  },
  "devDependencies": {
    "eslint": "8.57.1",
    "eslint-config-next": "14.2.15"
  }
}

Manually remove install-state.gz

bash
yarn install
yarn workspaces focus reproduce --production
rm .yarn/install-state.gz      # Mimic a remote/hermetic build that install-state doesn't transfer
yarn run start    # throws on couldn't find eslint , where eslint isn't required

Or commit a workspace-focus pnp for reproducing

bash
git init
yarn install
yarn workspaces focus reproduce --production
git add -A && git commit -m "zero-install"    # commits the focused .pnp.cjs
cd .. && git clone repo fresh
cd fresh && yarn run start                               # throws on eslint

Environment

bash
System:
    OS: Linux 7.0 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
  Binaries:
    Node: 18.19.1 - /tmp/xfs-779db9e0/node
    Yarn: 4.18.0-dev - /tmp/xfs-779db9e0/yarn
    npm: 9.2.0 - /usr/bin/npm