Minimal reproduction for a pnpm bug: any --filter argument passed to
pnpm --recursive run/exec causes the workspace root to be incorrectly
included in the matched set of workspace projects, contrary to the
documented default.
.
├── package.json # root, private
├── pnpm-workspace.yaml # packages: [a, b]
├── a/package.json
└── b/package.json
# Correct: root excluded
pnpm --recursive exec pwd
# a
# b
# Bug: root appears in output
pnpm --recursive --filter '!a' exec pwd
# b
# . <-- workspace root, should not be here| pnpm version | Behavior |
|---|---|
| 10.13.0 | ✅ root excluded (correct) |
| 10.33.0 | ❌ root included |
| 10.33.1 | ❌ root included |
| 11.0.0-rc.5 | ❌ root included |
Regression range: works in 10.13.0, broken by 10.33.0.
A common recursive invocation like
pnpm --recursive --filter '!frontend' --filter '!backend' run testwill attempt to run the test script on the root package in addition
to the filtered sub-packages. If the root has the script defined
(perhaps for a different purpose, e.g. aggregating via projects[] in a
Jest config), it will be executed unexpectedly.
includeWorkspaceRoot defaults to false, and explicitly setting it
does not change this behavior when filters are in use.