Skip to content

fix(misc): record pnpm 11 build script decisions in generators - #36814

Draft
leosvelperez wants to merge 4 commits into
masterfrom
nxc-4778
Draft

fix(misc): record pnpm 11 build script decisions in generators#36814
leosvelperez wants to merge 4 commits into
masterfrom
nxc-4778

Conversation

@leosvelperez

Copy link
Copy Markdown
Member

Current Behavior

pnpm 11 fails an install when a dependency runs a build script that the workspace has neither allowed nor denied. Nx generators end by running that install:

$ pnpm install --no-frozen-lockfile

[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: unrs-resolver@1.12.2

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

Some generators already write a decision for the packages they add. Many still do not, so those generators fail and leave the workspace half set up. nx new writes no decisions at all, and no generator can cover for it, because it installs the preset packages before the preset generator runs.

Expected Behavior

Every generator that adds a package with a build script writes a decision for it. nx new does the same for the packages its preset installs. pnpm 11 then installs without stopping. Nearly all scripts are skipped. Only Detox and the Angular Rspack compiler run theirs, because they need the script and the user asked for those packages by name. A decision the user already made is left alone.

Related Issue(s)

NXC-4778

Implementation Notes

  • A script is skipped unless the package needs it and the user asked for that package by name. The skipped ones ship prebuilt binaries as optional dependencies, fall back to a no-op, or only print a funding message.
  • The Angular generators share one helper. They install the same build toolchain, so one list keeps them from drifting apart.
  • nx new derives its decisions from the packages the chosen preset installs, and writes them into the pnpm-workspace.yaml it generates.
  • Checked against pnpm 11.22.0. All 18 preset and bundler combinations nx new can produce install cleanly with only these decisions. Removing them brings the failures back.

View Polygraph session ↗

@netlify

netlify Bot commented Aug 27, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit eb008f6
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a95a9680fcb130008d377bf
😎 Deploy Preview https://deploy-preview-36814--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 27, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit eb008f6
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a95a96836aff70009454fd4
😎 Deploy Preview https://deploy-preview-36814--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit eb008f6

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 49m 41s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 6s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m 2s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 19s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx affected -t e2e-macos-local --parallel=2 --b... ✅ Succeeded 34m 27s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-31 17:13:24 UTC

@leosvelperez leosvelperez self-assigned this Aug 27, 2026
nx-cloud[bot]

This comment was marked as outdated.

@leosvelperez
leosvelperez force-pushed the nxc-4778 branch 3 times, most recently from 95d3699 to 63105bd Compare August 31, 2026 13:47

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

pnpm 11 refuses to install a dependency whose build scripts are neither
allowed nor denied, and exits with ERR_PNPM_IGNORED_BUILDS. Generators
finish by running `installPackagesTask`, which shells out to `pnpm
install --no-frozen-lockfile` without `--ignore-scripts`, so a generator
that adds a package carrying an unrecorded install script fails outright
on pnpm 11.

Every generator that installs such a package now records a decision.
The decision is to skip the script unless it is required and the user
asked for that package directly, which leaves only detox and
@nx/angular-rspack-compiler running. The rest are skipped because the
package ships prebuilt binaries as optional dependencies, falls back to
a no-op when its build fails, or only prints a funding message. The
Angular generators share one helper, since they all install the same
build toolchain.

`nx new` needs its own path. It installs the preset dependencies before
the preset generator runs, so the generators that would otherwise record
these decisions come too late. The pnpm-workspace.yaml it writes now
carries them, derived from the preset dependency list.
The 23.1.0 migrations that backfill build tooling add packages carrying
install scripts. `add-angular-build` adds `@angular/build`, which depends
on esbuild and sass, and `add-optional-webpack-packages` adds `@nx/webpack`
or `@nx/rspack`, which depend on sass. pnpm 11 refuses to install a
dependency whose build scripts are neither allowed nor denied, and exits
with ERR_PNPM_IGNORED_BUILDS.

`nx migrate` installs with `--ignore-scripts`, so the migration run itself
completes and the failure only surfaces on the next clean install. Both
migrations now record the same decisions the corresponding generators
already record. `add-optional-webpack-packages` records nothing when only
`@nx/module-federation` is added, since that package carries no install
script.
…tall

`nx new --preset=react-native` and `--preset=expo` failed on pnpm 11 with
`ERR_PNPM_IGNORED_BUILDS: unrs-resolver`, leaving the workspace half created.
Both presets reach `unrs-resolver` through their optional `@nx/detox`
dependency and jest 30, and the preset build-script table had no entry for
either one.

`@nx/storybook:configuration` failed the same way on its default path.
`@storybook/test-runner` was accounted for through `@swc/core` alone, but the
0.24 line it installs for Storybook 10 also runs on jest 30. The runner lines
Storybook 8 and 9 select stay on jest 29, so the new decision is gated on the
resolved runner version and those workspaces record nothing extra.

Creating a workspace from a custom preset resolved that preset's version from
the registry twice, once to build the pnpm settings and once to add the
dependency. `generateWorkspaceFiles` now resolves it once and hands the result
to `addPresetDependencies`.

Two comments described versions the generators do not install: vite 5 in remix
where `viteVersion` is `^6.0.0`, and an `esbuild-register` hop that storybook
dropped in v10. Both now name the direct dependency.

Negative tests that asserted a decision is absent from a file the generator
never writes now assert the file's absence instead.
…migrations

Both pages described their migration as editing `package.json` alone. On pnpm
11 and above each one also records `allowBuilds` decisions in
`pnpm-workspace.yaml`, so a user reading the migration diff found entries the
page never mentioned.

The `add-angular-build` example pinned `@angular/build` at `~22.0.4`, while
the migration installs `angularDevkitVersion`, which is `~22.1.0`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant