From 595cd414f8a3277f91c8a50b957313edb4e59f78 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 9 Feb 2026 02:21:46 +0100 Subject: [PATCH] revert: "fix: allow pnpm run -r to work with empty pnpm-workspace.yaml (#10578) * revert: "fix: allow pnpm `run -r` to work with empty pnpm-workspace.yaml (#10520)" This reverts commit f1cb40c4e1fb689bab4eedb56172fa7bb50c2009. * revert: "test: fix" This reverts commit 1dbbffb6adfc21722692e473cc2feac4ef805cc1. * docs: add changeset close #10571 --- .changeset/upset-badgers-dance.md | 8 ++++++++ config/config/src/index.ts | 2 +- pnpm/src/main.ts | 2 +- pnpm/test/monorepo/index.ts | 16 ---------------- 4 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 .changeset/upset-badgers-dance.md diff --git a/.changeset/upset-badgers-dance.md b/.changeset/upset-badgers-dance.md new file mode 100644 index 0000000000..5d58fcfd97 --- /dev/null +++ b/.changeset/upset-badgers-dance.md @@ -0,0 +1,8 @@ +--- +"@pnpm/config": patch +"pnpm": patch +--- + +Reverted a fix shipped in v10.29.1, which caused another issue [#10571](https://github.com/pnpm/pnpm/issues/10571). +Reverted fix: Fixed pnpm run -r failing with "No projects matched the filters" when an empty pnpm-workspace.yaml exists [#10497](https://github.com/pnpm/pnpm/issues/10497). + diff --git a/config/config/src/index.ts b/config/config/src/index.ts index 2a04b793c6..12649a22ee 100644 --- a/config/config/src/index.ts +++ b/config/config/src/index.ts @@ -367,7 +367,7 @@ export async function getConfig (opts: { if (pnpmConfig.workspaceDir != null) { const workspaceManifest = await readWorkspaceManifest(pnpmConfig.workspaceDir) - pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages + pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? ['.'] if (workspaceManifest) { const newSettings = Object.assign(getOptionsFromPnpmSettings(pnpmConfig.workspaceDir, workspaceManifest, pnpmConfig.rootProjectManifest), configFromCliOpts) for (const [key, value] of Object.entries(newSettings)) { diff --git a/pnpm/src/main.ts b/pnpm/src/main.ts index 527441d9e8..6a478b1adf 100644 --- a/pnpm/src/main.ts +++ b/pnpm/src/main.ts @@ -213,7 +213,7 @@ export async function main (inputArgv: string[]): Promise { const relativeWSDirPath = () => path.relative(process.cwd(), wsDir) || '.' if (config.workspaceRoot) { filters.push({ filter: `{${relativeWSDirPath()}}`, followProdDepsOnly: Boolean(config.filterProd.length) }) - } else if (filters.length === 0 && workspaceDir && config.workspacePackagePatterns && !config.includeWorkspaceRoot && (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')) { + } else if (filters.length === 0 && workspaceDir && !config.includeWorkspaceRoot && (cmd === 'run' || cmd === 'exec' || cmd === 'add' || cmd === 'test')) { filters.push({ filter: `!{${relativeWSDirPath()}}`, followProdDepsOnly: Boolean(config.filterProd.length) }) } diff --git a/pnpm/test/monorepo/index.ts b/pnpm/test/monorepo/index.ts index 4301a2ba45..07339ca830 100644 --- a/pnpm/test/monorepo/index.ts +++ b/pnpm/test/monorepo/index.ts @@ -61,22 +61,6 @@ test('no projects found', async () => { } }) -test('empty pnpm-workspace.yaml should not break pnpm run -r', async () => { - prepare({ - name: 'project', - version: '1.0.0', - scripts: { - test: 'echo Passed', - }, - }) - - fs.writeFileSync('pnpm-workspace.yaml', '') - - const { stdout, status } = execPnpmSync(['run', '-r', 'test']) - expect(status).toBe(0) - expect(stdout.toString()).toContain('Passed') -}) - const invalidWorkspaceManifests = [ 'pnpm-workspaces.yaml', 'pnpm-workspaces.yml',