Skip to content

fix(core): allow nx build scripts in generated pnpm-workspace.yaml#35564

Open
cogwirrel wants to merge 2 commits intonrwl:masterfrom
cogwirrel:pnpm-11-support
Open

fix(core): allow nx build scripts in generated pnpm-workspace.yaml#35564
cogwirrel wants to merge 2 commits intonrwl:masterfrom
cogwirrel:pnpm-11-support

Conversation

@cogwirrel
Copy link
Copy Markdown
Contributor

@cogwirrel cogwirrel commented May 5, 2026

Current Behavior

When creating a new workspace with create-nx-workspace using the preset flow and pnpm 11, the workspace creation fails at the nx new step with:

ERR_PNPM_IGNORED_BUILDS  Ignored build scripts: nx@22.7.0

Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.

 NX   Command failed: pnpm install --no-frozen-lockfile

pnpm 11 defaults strictDepBuilds to true, which turns the warning for ignored build scripts into a hard error. addPnpmSettings writes a minimal pnpm-workspace.yaml containing only autoInstallPeers: true — it does not include allowBuilds, so when installPackagesTask runs pnpm install --no-frozen-lockfile, pnpm sees that nx has a postinstall script and errors out because it is not in the allowlist.

Expected Behavior

Workspace creation should succeed under pnpm 11 without requiring the user to manually configure allowBuilds or downgrade pnpm. The generated pnpm-workspace.yaml should include the correct build allowlist key for the detected pnpm version.

This PR uses getPackageManagerVersion (already available in generateWorkspaceFiles) to emit only the correct key:

  • pnpm 11+: allowBuilds: { nx: true } — the new pnpm 11 setting
  • pnpm 10.6.0–10.x: onlyBuiltDependencies: [nx] — the pnpm 10 setting

pnpm 11 removed onlyBuiltDependencies entirely in favor of allowBuilds, so we version-gate rather than emitting both.

Related Issue(s)

Fixes #35563

pnpm 11 defaults strictDepBuilds to true. When create-nx-workspace runs
a third-party preset (anything that hits the createEmptyWorkspace +
createPreset code path), the initial `pnpm install --no-frozen-lockfile`
fires ERR_PNPM_IGNORED_BUILDS for nx's postinstall script and the
workspace-creation step fails before the preset can run.

Extend addPnpmSettings to emit an allowBuilds entry for nx in the
generated pnpm-workspace.yaml, so the initial install succeeds. Include
the pnpm 10-compatible onlyBuiltDependencies form as well — pnpm silently
ignores the key it doesn't recognize.
@cogwirrel cogwirrel requested a review from a team as a code owner May 5, 2026 01:29
@cogwirrel cogwirrel requested a review from MaxKless May 5, 2026 01:29
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 585b4a0

@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 585b4a0

Copy link
Copy Markdown
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the PR - I left a comment that I think we can get this past the line after solving

@AgentEnder
Copy link
Copy Markdown
Member

Ah, github has issues - the comment was meant to be:

We should have access to getPackageMangerVersion so we can only generate the correct key

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 6, 2026

View your CI Pipeline Execution ↗ for commit c7cbfa8

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ⛔ Cancelled 47s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 17s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 24s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-06 18:48:23 UTC

@cogwirrel
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! Updated to use getPackageManagerVersion (already available in generateWorkspaceFiles) to conditionally emit only the correct key:

  • pnpm >= 11.0.0: allowBuilds: { nx: true }
  • pnpm 10.6.0–10.x: onlyBuiltDependencies: [nx]

Will push shortly.

@cogwirrel
Copy link
Copy Markdown
Contributor Author

Hey, thanks for the PR - I left a comment that I think we can get this past the line after solving

Thanks @AgentEnder! Good call, have updated the PR to switch on pnpm >=11 :)

…ace.yaml

Use getPackageManagerVersion to emit only the correct key:
- pnpm 11+: allowBuilds (the new pnpm 11 setting)
- pnpm 10.6.0-10.x: onlyBuiltDependencies (the pnpm 10 setting)
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.

create-nx-workspace fails with pnpm 11 when using --preset (ERR_PNPM_IGNORED_BUILDS)

2 participants