Skip to content

[rush] Add pnpm 11 support: allowBuilds in pnpm-workspace.yaml#5817

Merged
iclanton merged 4 commits into
mainfrom
copilot/rush-51751-pnpm-1111-fix
Jun 7, 2026
Merged

[rush] Add pnpm 11 support: allowBuilds in pnpm-workspace.yaml#5817
iclanton merged 4 commits into
mainfrom
copilot/rush-51751-pnpm-1111-fix

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

pnpm 11 removed support for the pnpm field in package.json (including onlyBuiltDependencies/neverBuiltDependencies) and replaced it with allowBuilds: Record<string, boolean> in pnpm-workspace.yaml. Rush was still writing the old fields, causing [ERR_PNPM_IGNORED_BUILDS] on every install, and rush-pnpm approve-builds would run but never update any config files.

Changes

New globalAllowBuilds config field (pnpm 11+)

  • Added globalAllowBuilds?: Record<string, boolean> to pnpm-config.json schema and PnpmOptionsConfiguration
  • Written to allowBuilds in the generated pnpm-workspace.yaml during installation
  • true = package allowed to run build scripts; false = explicitly denied
// common/config/rush/pnpm-config.json
{
  "globalAllowBuilds": {
    "esbuild": true,
    "@parcel/watcher": true,
    "fsevents": false
  }
}

Backward compatibility

When using pnpm 11 with the old globalOnlyBuiltDependencies/globalNeverBuiltDependencies fields, Rush automatically converts them to allowBuilds format (entries become true/false respectively) and emits a deprecation warning directing users to migrate to globalAllowBuilds.

InstallHelpers.ts

For pnpm ≥ 11.0.0, skips writing neverBuiltDependencies/onlyBuiltDependencies to common/temp/package.json (pnpm 11 ignores the pnpm field entirely).

approve-builds command

For pnpm ≥ 11.0.0, rush-pnpm approve-builds now correctly reads the updated allowBuilds map from pnpm-workspace.yaml (written by pnpm approve-builds) and persists it back to pnpm-config.json as globalAllowBuilds, then re-runs rush update. Previously this was reading from package.json which pnpm 11 no longer updates.

Copilot AI changed the title [WIP] Fix compatibility issue between Rush 5.175.1 and pnpm 11.1.1 [rush] Add pnpm 11 support: allowBuilds in pnpm-workspace.yaml Jun 4, 2026
Copilot AI requested a review from iclanton June 4, 2026 01:18
@iclanton
iclanton marked this pull request as ready for review June 6, 2026 22:34
@iclanton
iclanton enabled auto-merge (squash) June 6, 2026 22:34
Comment thread libraries/rush-lib/src/logic/installManager/InstallHelpers.ts Outdated
Comment thread libraries/rush-lib/src/schemas/pnpm-config.schema.json
Comment thread libraries/rush-lib/src/cli/RushPnpmCommandLineParser.ts Outdated
@iclanton
iclanton disabled auto-merge June 6, 2026 23:18
@iclanton

iclanton commented Jun 6, 2026

Copy link
Copy Markdown
Member

@copilot - take a look at the comments on the PR and respond and address them.

@iclanton
iclanton enabled auto-merge (squash) June 6, 2026 23:47
@iclanton

iclanton commented Jun 7, 2026

Copy link
Copy Markdown
Member

@copilot - the build failed. The API report file needs to be updated.

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot - the build failed. The API report file needs to be updated.

Fixed in the latest commit. Updated common/reviews/api/rush-lib.api.md to add globalAllowBuilds to _IPnpmOptionsJson, globalAllowBuilds as a readonly property to PnpmOptionsConfiguration, and the new updateGlobalAllowBuilds method.

@iclanton
iclanton merged commit 7148e57 into main Jun 7, 2026
9 checks passed
@iclanton
iclanton deleted the copilot/rush-51751-pnpm-1111-fix branch June 7, 2026 00:40
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Jun 7, 2026
iclanton added a commit that referenced this pull request Jul 16, 2026
* [rush] Write pnpm global settings to pnpm-workspace.yaml for pnpm 11

pnpm 11 no longer reads the "pnpm" field of package.json, so the settings
Rush serialized there were silently ignored. Relocate globalOverrides,
globalPackageExtensions, globalPeerDependencyRules,
globalAllowedDeprecatedVersions, and globalPatchedDependencies to the
generated common/temp/pnpm-workspace.yaml for pnpm >= 11.0.0, mirroring the
allowBuilds relocation from #5817. Behavior for older pnpm is unchanged.

Fixes #5837

* [rush] Add change file for pnpm 11 settings relocation

Co-references #5837

* [rush] Fix rush-pnpm patch-commit for pnpm 11 and add coverage

Two fixes from adversarial review of the pnpm 11 settings relocation:

1. rush-pnpm patch-commit / patch-remove read patchedDependencies from
   common/temp/package.json, which pnpm 11 no longer populates. They now read
   patchedDependencies from common/temp/pnpm-workspace.yaml for pnpm >= 11
   (mirroring the approve-builds allowBuilds path), preserving the package.json
   path for pnpm < 11 and the existing subspace + patches-folder logic.

2. Added integration coverage:
   - InstallHelpers.generateCommonPackageJson omits the relocated settings from
     package.json for pnpm 11 and still writes them for pnpm < 11.
   - RushPnpmCommandLineParser reads patchedDependencies from pnpm-workspace.yaml
     for pnpm 11 and from package.json for pnpm < 11.

Refs #5837

* [rush] Revert unrelated formatter changes

* [rush] Remove unecessary checks

* [rush] Move patch dependencies and yaml handling to PnpmWorkspaceFile as a helper

* [rush] Remove unecessary test setup

---------

Co-authored-by: Bruno Paulino <brunojppb@users.noreply.github.com>
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[rush] Rush 5.175.1 and pnpm 11.1.1 do not work together (build scripts issues)

3 participants