fix(config): apply pmOnFail default to devEngines.packageManager (singular)#11682
Conversation
…gular)
The pnpm v11 release notes document the `pmOnFail` default as `download`
(via the migration table that maps `managePackageManagerVersions: true` →
`pmOnFail: download (default)`). The legacy `packageManager` field already
gets that default applied at the central onFail-resolution site, but the
singular form of `devEngines.packageManager` short-circuited it by setting
`onFail = 'error'` inside `parseDevEnginesPackageManager`, so projects that
pinned a different pnpm via `devEngines.packageManager` saw a hard version
mismatch instead of an auto-download.
Drop that local `?? 'error'` and let the central default apply. The array
form of `devEngines.packageManager` keeps its own per-element defaults
('error' for the last entry, 'ignore' for the rest) — those reflect
explicit prioritisation by the user, not a system-wide fallback. Explicit
`onFail` values are still honored everywhere.
Closes pnpm#11676.
cspell flagged the British spelling at pre-push.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.test.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2026-05-14T09:04:00.133ZApplied to files:
🔇 Additional comments (4)
📝 WalkthroughWalkthroughFixes the ChangespmOnFail Defaulting Precedence Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@zkochan what do you think about this change? From a quick look, it seems like an ok approach to leave |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Summary
Closes #11676.
The pnpm v11 release notes migration table documents the
pmOnFaildefault asdownload:managePackageManagerVersions: truepmOnFail: download(default)The legacy
packageManagerfield already gets that default applied at the central onFail-resolution site ingetConfig— but the singular form ofdevEngines.packageManagershort-circuited it by settingonFail = 'error'insideparseDevEnginesPackageManager. So a project that pinned a different pnpm viadevEngines.packageManagerand ranpnpm installfrom a mismatched pnpm saw a hard version mismatch error instead of the auto-download the docs promise.Reproduction (from the issue):
After this PR, the same install resolves to
onFail: 'download'and switches to the wanted version, matchingpnpm install --pm-on-fail=download.The change
parseDevEnginesPackageManager(singular case) no longer applies a local?? 'error'default. The localonFailis leftundefinedwhen the user didn't set it, so the centralpmOnFaildefault atgetConfigline ~666 picks up'download'.The array form of
devEngines.packageManagerkeeps its existing per-element defaults ('error'for the last entry,'ignore'for the rest). Those reflect explicit prioritization by the user (alternatives list), not a system-wide fallback, so they should stay.Explicit
onFailvalues continue to win in all cases.Behavior change
This is technically a behavior change: previously
devEngines.packageManager: { name: 'pnpm', version: '<other>' }(noonFail) errored out; now it switches versions. That matches the documented contract. The pre-existing testdevEngines.packageManager defaults to onFail=errorcemented the buggy behavior — it has been retargeted to assert the new default (onFail=download) using the corepack-fallthrough pattern from the adjacentonFail=download surfaces a regular error under corepacktest, so the assertion stays fast and deterministic without a real download round-trip.Test plan
config/reader/test/index.ts:devEngines.packageManager without onFail resolves to the documented pmOnFail default "download" (#11676)devEngines.packageManager with explicit onFail is respected (regression guard for #11676)devEngines.packageManager defaults to onFail=download (#11676)inpnpm/test/packageManagerCheck.test.ts— asserts the corepack-fallthrough behavior that confirms the resolved default isdownload.wantedPackageManager.onFailresolves todownloadwhen not set, stays aserrorwhen explicitly set.Local Jest still fails for me with
module is already linkedunderexperimental-vm-moduleson Node 22/24 (env issue, reproduces on pristinemain) — relying on CI for the real test run.pacquet parity note
Config-reader change. Pacquet currently install-only and does not consume
devEngines.packageManagerdefaults yet. Flagging perCLAUDE.mdso the parity shows up on the radar if/when pacquet grows this surface.Written by an agent (Claude Code, claude-opus-4-7).
Summary by CodeRabbit
Release Notes
Bug Fixes
downloadbehavior whenonFailis not explicitly specified.Documentation
Tests