Conversation
When `package.json` declares both `packageManager` and `devEngines.packageManager`, `pnpm self-update` previously bumped only the latter — leaving Corepack (which reads `packageManager`) pinned to the old version until a manual edit. Now, when `packageManager` pins pnpm, both fields are rewritten to the new exact version on update: `packageManager` to `pnpm@<version>` (without an integrity hash) and `devEngines.packageManager.version` to the same exact `<version>` (dropping any range operator). When only `devEngines.packageManager` is declared, the existing range-preserving behavior is unchanged. Closes #11388
Drop the inline duplicate in self-updater and use the existing parser from config.reader. Same parsing rules (strips integrity hash, rejects URL-style refs).
Resolve to the underlying pnpm entry first (whether the field is an array or an object) and run the version-update logic once, instead of duplicating it across both branches.
zkochan
added a commit
that referenced
this pull request
Apr 29, 2026
…#11395) * fix: sync packageManager and devEngines.packageManager on self-update When `package.json` declares both `packageManager` and `devEngines.packageManager`, `pnpm self-update` previously bumped only the latter — leaving Corepack (which reads `packageManager`) pinned to the old version until a manual edit. Now, when `packageManager` pins pnpm, both fields are rewritten to the new exact version on update: `packageManager` to `pnpm@<version>` (without an integrity hash) and `devEngines.packageManager.version` to the same exact `<version>` (dropping any range operator). When only `devEngines.packageManager` is declared, the existing range-preserving behavior is unchanged. Closes #11388 * refactor: export and reuse parsePackageManager from @pnpm/config.reader Drop the inline duplicate in self-updater and use the existing parser from config.reader. Same parsing rules (strips integrity hash, rejects URL-style refs). * refactor: collapse devEngines.packageManager array/object branches Resolve to the underlying pnpm entry first (whether the field is an array or an object) and run the version-update logic once, instead of duplicating it across both branches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
package.jsondeclares bothpackageManageranddevEngines.packageManager,pnpm self-updatepreviously bumped only the latter — leaving Corepack (which readspackageManager) pinned to the old version until a manual edit.packageManagerpins pnpm, both fields are rewritten to the new exact version on update:packageManagertopnpm@<version>(without an integrity hash) anddevEngines.packageManager.versionto the same exact<version>(dropping any range operator).devEngines.packageManageris declared, the existing range-preserving behavior is unchanged. WhenpackageManagerpins something other than pnpm (e.g. yarn), it is left alone.Closes #11388
Test plan
+sha512…integrity hash → both bumped, hash dropped.selfUpdate.test.tspass.