Skip to content

pnpm --recursive + --filter includes workspace root (regression since 10.33.0) #11341

@shoebox639

Description

@shoebox639

Verify latest release

  • I verified that the issue exists in the latest pnpm release (10.33.1, and in 11.0.0-rc.5)

pnpm version

10.33.0 (also confirmed in 10.33.1 and 11.0.0-rc.5)

Which area(s) of pnpm are affected?

CLI

Link to the code that reproduces this issue

https://github.com/shoebox639/pnpm-recursive-filter-root-bug

Reproduction steps

git clone https://github.com/shoebox639/pnpm-recursive-filter-root-bug.git
cd pnpm-recursive-filter-root-bug

# Correct: root excluded
pnpm --recursive exec pwd
# a
# b

# Bug: root appears in output when any --filter is passed
pnpm --recursive --filter '!a' exec pwd
# b
# .   <-- workspace root, should not be here

The workspace has only a root package.json (private: true) and two sub-packages a and b. No includeWorkspaceRoot setting is configured anywhere.

Describe the Bug

When any --filter argument is passed to pnpm --recursive run/exec, the workspace root package is included in the matched set of workspace projects, contrary to the documented default:

Runs a command in every project of a workspace, excluding the root project, when used with the following commands: exec, run, test, add.

Without any --filter, the root is correctly excluded. As soon as any --filter (positive or negative) is present, pnpm begins treating the workspace root as one of the matched projects.

The Scope: line in -r output makes this visible in 11.0.0-rc.5:

$ pnpm --recursive --filter '!a' exec pwd
Scope: all 3 workspace projects   <-- includes root

Explicitly setting include-workspace-root=false (the default) does not change this behavior when filters are in use.

Affected versions

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.

Expected Behavior

Per the cli/recursive docs, the workspace root should be excluded from -r run/exec/test/add regardless of whether --filter arguments are passed, unless includeWorkspaceRoot: true is explicitly configured.

Which Node.js version are you using?

22.21.0

Which operating systems have you used?

  • macOS

If your OS is a Linux based, which one it is?

N/A — reproduced on macOS 26.4.1 (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions