Skip to content

fix: default to ['.'] for workspacePackagePatterns when packages field is missing#10996

Merged
zkochan merged 12 commits intopnpm:mainfrom
dasa:fix/10909
Mar 18, 2026
Merged

fix: default to ['.'] for workspacePackagePatterns when packages field is missing#10996
zkochan merged 12 commits intopnpm:mainfrom
dasa:fix/10909

Conversation

@dasa
Copy link
Copy Markdown
Contributor

@dasa dasa commented Mar 17, 2026

Fixes #10909.

When pnpm-workspace.yaml exists without a packages field, workspacePackagePatterns was left as undefined, causing findPackages to use its default ['.', '**'] pattern. This treated all directories with a package.json as workspace projects, breaking projects that use pnpm-workspace.yaml only for settings (e.g. minimumReleaseAge).

The fix adds ?? ['.'] in the config reader so that a workspace yaml without packages defaults to root-only discovery. This was originally fixed in #10927 but lost during a merge.

…s missing (pnpm#10927)

* fix: restore ['.'] default for workspacePackagePatterns when packages field is missing

Commit 6eedf82 removed the ['.'] fallback for workspacePackagePatterns
when pnpm-workspace.yaml has no packages field. This caused findPackages
to default to ['.', '**'], discovering ALL directories with package.json
as workspace projects. This is the same regression that was previously
reverted in 595cd41 (close pnpm#10571), reintroduced by pnpm#10127.

Projects like cdxgen that use pnpm-workspace.yaml only for settings
(e.g. minimumReleaseAge) without a packages field were broken because
test data directories were picked up as workspace projects.

close pnpm#10909

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove unknown word from changeset

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test(config): verify workspacePackagePatterns defaults to ['.'] without packages field

Adds a regression test to ensure pnpm-workspace.yaml without a packages
field defaults workspacePackagePatterns to ['.'] (root only), preventing
all directories from being discovered as workspace projects.

(cherry picked from commit 5163697)
@dasa dasa requested a review from zkochan as a code owner March 17, 2026 16:37
@dasa
Copy link
Copy Markdown
Contributor Author

dasa commented Mar 17, 2026

This seems to be hitting the same issue that #10578 was reverted for. Should that be reverted on main too?

@zkochan
Copy link
Copy Markdown
Member

zkochan commented Mar 18, 2026

I don't know. I was not the author of the change: #10127

@dasa
Copy link
Copy Markdown
Contributor Author

dasa commented Mar 18, 2026

@KSXGitHub any ideas here? I'm just worried that #10909 will become an issue again in v11.0.0.

dasa and others added 2 commits March 18, 2026 14:49
Move the fix from config reader to findPackages, where the overly broad
default pattern was the root cause of both pnpm#10909 and pnpm#10571. This keeps
workspacePackagePatterns as undefined when packages field is missing,
preserving PR pnpm#10127's fix for filter in pnpm-workspace.yaml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zkochan zkochan changed the title fix: restore default workspace package patterns when packages field is missing fix: change default findPackages pattern to only match root Mar 18, 2026
zkochan and others added 5 commits March 18, 2026 23:26
Tests now explicitly define workspace packages via pnpm-workspace.yaml
and use shared-workspace-lockfile=false to maintain per-project
node_modules, matching the pre-change behavior after the findPackages
default pattern changed from ['.', '**'] to ['.'].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…change

Tests that use preparePackages + filterProjectsBySelectorObjectsFromDir
now write pnpm-workspace.yaml with packages: ['*'] before project
discovery, since findPackages no longer defaults to scanning all
subdirectories.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ot provided

Make filterProjectsFromDir consistent with filterProjectsBySelectorObjectsFromDir
by reading pnpm-workspace.yaml to get package patterns when none are
passed explicitly. Previously relied on findPackages defaulting to
['.', '**'].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Revert the findPackages default back to ['.', '**'] so that behavior
is unchanged when there is no pnpm-workspace.yaml. Instead, handle the
"workspace yaml exists without packages field" case at the three call
sites that read the workspace manifest:

- filterProjectsBySelectorObjectsFromDir
- filterProjectsFromDir
- config.reader getConfig

When workspace yaml exists but has no packages field, explicitly use
['.'] (root only). When there is no workspace yaml, leave patterns as
undefined so findPackages uses its default ['.', '**'].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…merge

The merge of main into this branch lost the `?? ['.']` fallback from
commit 844dea8. This caused pnpm-workspace.yaml without a packages
field to fall through to findPackages default of ['.', '**'], treating
all directories as workspace projects.

Reverts the unnecessary changes to findPackages, filterProjectsFromDir,
and filterProjectsBySelectorObjectsFromDir, as well as all test file
workarounds that were only needed because the fix was in the wrong place.

The fix is a single line in config/reader: adding `?? ['.']` when
workspaceManifest.packages is undefined.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zkochan
Copy link
Copy Markdown
Member

zkochan commented Mar 18, 2026

ok, I went full cycle. This solution is correct.

@zkochan zkochan changed the title fix: change default findPackages pattern to only match root fix: default to ['.'] for workspacePackagePatterns when packages field is missing Mar 18, 2026
@zkochan zkochan merged commit 2e55dcf into pnpm:main Mar 18, 2026
5 of 6 checks passed
@dasa dasa deleted the fix/10909 branch March 19, 2026 16:06
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 install fails for cdxgen

2 participants