Skip to content

fix(global): preserve build approvals and dlx behavior#10492

Open
EDM115 wants to merge 2 commits intopnpm:mainfrom
EDM115:edm115/fix-global-approve-builds
Open

fix(global): preserve build approvals and dlx behavior#10492
EDM115 wants to merge 2 commits intopnpm:mainfrom
EDM115:edm115/fix-global-approve-builds

Conversation

@EDM115
Copy link
Copy Markdown

@EDM115 EDM115 commented Jan 21, 2026

Important

Full disclosure : Most of the code here has been written by GPT 5.2 Codex.
Please review the changes to see if there is any glaring mistake or flaw in the implementation 🙏

Summary

  • preserve global build approvals and avoid rewriting global workspace manifests
  • allow pnpm dlx when dangerouslyAllowAllBuilds is enabled
  • improve global ignored-builds hint and add tests for that

Details

  1. When running pnpm approve-builds -g (after a pnpm up -L -g for instance), any existing entry in allowBuilds won't be overwritten or just removed from either the global pnpm-workspace.yaml or pnpm key in the global package.json
  2. When running pnpm config set dangerouslyAllowAllBuilds true followed by a pnpm dlx command, we will no longer see the CONFIG_CONFLICT_BUILT_DEPENDENCIES error
  3. When installing/updating a global dependency, the message thrown by IgnoredBuildsError will indicate to run pnpm approve-builds with the -g flag (was that a regression of v11 ? I believe it was present before in v10 iirc)

Issues

Closes #10121
Closes #8891

preserve global workspace manifest settings and merge allowBuilds during global installs

avoid dlx allow-build conflicts when dangerouslyAllowAllBuilds is enabled

Closes pnpm#10121

Closes pnpm#8891
adjust the ignored builds hint to include -g for global runs

add coverage for global and non-global hint rendering
@EDM115 EDM115 requested a review from zkochan as a code owner January 21, 2026 11:30
Copilot AI review requested due to automatic review settings January 21, 2026 11:30
@EDM115
Copy link
Copy Markdown
Author

EDM115 commented Jan 21, 2026

Note

These changes do not touch onlyBuiltDependencies and ignoredBuiltDependencies because from what I understand in https://pnpm.io/settings#build-settings allowBuilds is what should be only used moving forward ?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issues related to preserving global build approvals and enabling pnpm dlx to work with dangerouslyAllowAllBuilds. The changes ensure that global workspace manifests are not unnecessarily rewritten and that build approval configurations are properly merged rather than replaced.

Changes:

  • Conditional workspace manifest updates to skip rewriting when performing global operations
  • Merge existing allowBuilds configurations when adding new packages with --allow-build flag
  • Add global flag parameter to IgnoredBuildsError to provide correct hint for global installs
  • Allow pnpm dlx to function when dangerouslyAllowAllBuilds is enabled

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm/test/install/global.ts Added tests to verify global workspace manifests are preserved and allowBuilds are merged correctly
pnpm/test/dlx.ts Added test to verify dlx works with dangerouslyAllowAllBuilds enabled
pkg-manager/plugin-commands-installation/src/remove.ts Added conditional check to skip workspace manifest updates for global operations
pkg-manager/plugin-commands-installation/src/recursive.ts Pass global flag to IgnoredBuildsError for proper hint messages
pkg-manager/plugin-commands-installation/src/installDeps.ts Added conditional checks to skip workspace manifest updates for global operations
pkg-manager/plugin-commands-installation/src/add.ts Spread existing allowBuilds to preserve them when adding new packages
pkg-manager/core/test/install/ignoredBuildsHint.ts Tests for global flag in IgnoredBuildsError hint messages
pkg-manager/core/src/install/index.ts Updated IgnoredBuildsError to accept global option and include -g flag in hint
exec/plugin-commands-script-runners/test/utils/index.ts Added dangerouslyAllowAllBuilds to test defaults
exec/plugin-commands-script-runners/src/dlx.ts Handle dangerouslyAllowAllBuilds by conditionally setting allowBuilds to undefined
.changeset/tiny-shoes-fold.md Changeset documentation for the fixes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


await execPnpm(['add', '--global', '--allow-build=esbuild', 'is-positive'], { env })

const updatedManifest = readYamlFile<{ allowBuilds?: Record<string, boolean> }>(workspaceManifestPath)
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The type annotation for the generic parameter should be Record<string, boolean | string> instead of Record<string, boolean> to match the actual type of allowBuilds used throughout the codebase. While boolean values are valid, the config also supports string values for version-specific specifications.

Suggested change
const updatedManifest = readYamlFile<{ allowBuilds?: Record<string, boolean> }>(workspaceManifestPath)
const updatedManifest = readYamlFile<{ allowBuilds?: Record<string, boolean | string> }>(workspaceManifestPath)

Copilot uses AI. Check for mistakes.
return resolved.id
}))
const allowBuildsFromCli = opts.allowBuild ?? []
const shouldAllowBuilds = !opts.dangerouslyAllowAllBuilds
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The variable name shouldAllowBuilds is misleading. It's set to !opts.dangerouslyAllowAllBuilds, which means when builds should be unrestricted (dangerouslyAllowAllBuilds=true), the variable is false. Consider renaming to shouldRestrictBuilds or strictBuildRestrictions to make the logic clearer.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this boolean name doesn't make sense.

@EDM115
Copy link
Copy Markdown
Author

EDM115 commented Jan 21, 2026

waiting for an actual maintainer to tell me if I should go ahead with Copilot's suggestions 😄

@EDM115
Copy link
Copy Markdown
Author

EDM115 commented Jan 21, 2026

any clue as to why certain tests fail on some Node versions but succeed on others ? 😅

Copy link
Copy Markdown
Member

@zkochan zkochan left a comment

Choose a reason for hiding this comment

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

I'd expect two separate PRs but these changes don't really seem to make sense to me.

@EDM115
Copy link
Copy Markdown
Author

EDM115 commented Feb 6, 2026

I'd expect two separate PRs

so one PR for the build approval preservation and another PR to fix the dlx + dangerouslyAllowAllBuilds issue ? just to be sure I don't misinterpret

these changes don't really seem to make sense to me

as in the code change themselves or why this PR exists in the first place ?
I can confirm that the changes indeed fix both issues but maybe the implementation isn't correct ?

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.

Cannot use pnpm dlx when dangerouslyAllowAllBuilds is true Allow setting onlyBuiltDependencies globally

3 participants