Repository navigation
fix(self-update): swap to pnpm package on Intel Mac when upgrading to v11+ - #11458
Merged
Merged
Conversation
… v11+ When self-updating from a v10 @pnpm/exe install on Intel macOS (darwin-x64) to a v11+ version, transparently install the JS-only "pnpm" npm package instead of @pnpm/exe. @pnpm/exe v11+ no longer ships a darwin-x64 binary because Node.js SEA injection produces a binary that segfaults on Intel Macs (upstream nodejs/node#62893; #11423). Without this swap, self-update would resolve @pnpm/exe@11.x, install a manifest with no platform binary, and leave the user with a broken bin shim. The new install requires Node.js on PATH; a globalWarn explains the swap when it happens. All other host/version combinations are unchanged. The targetPkgName is also threaded through getToolDirPath, the `pnpm add` command, and the linkExePlatformBinary guard so the new install lives under the correct tool directory and the @pnpm/exe-specific platform-binary linking is skipped for the JS path.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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
v10 backport companion to #11455 (which drops
darwin-x64from@pnpm/exein v11).When a v10 user on Intel macOS runs
pnpm self-updateand resolves a v11+ target, today's behavior would be:installPnpmToToolsresolves@pnpm/exe@11.xfrom the registry.@pnpm/macos-x64inoptionalDependencies(per fix(exe): drop darwin-x64 artifact (upstream Node SEA bug) #11455), so no platform binary is installed.linkExePlatformBinaryearly-returns silently becausenode_modules/@pnpm/macos-x64/pnpmdoesn't exist.linkBinsruns but there's nothing useful to link — the user is left with no workingpnpm.This PR teaches v10's
installPnpmToToolsto detect that exact scenario (current pkg is@pnpm/exe, host isdarwin-x64, target version is v11+) and transparently swap the install target from@pnpm/exeto the JS-onlypnpmnpm package. Thepnpmpackage runs against the user's system Node.js, which on Intel Mac is the only path that still works.Changes
tools/plugin-commands-self-updater/src/installPnpmToTools.ts:targetPkgNamederived fromcurrentPkgNameplus the host/version check. Threaded throughgetToolDirPath(so the install lives under the right tool dir), thepnpm addcommand, and thelinkExePlatformBinaryguard (skipped when not installing@pnpm/exe).globalWarnprinted when the swap happens, calling out that the new install requires Node.js onPATHand pointing at pnpm 11.0.3 standalone executable segfaults on Intel macOS (upstream Node.js SEA bug) #11423.semverand@pnpm/loggerimports (both already independencies/peerDependencies).Plus a changeset.
What this is and isn't
@pnpm/exeIntel-Mac users so they're not left with a broken bin shim afterpnpm self-update. Future self-updates from the v11pnpmpackage go through v11's own self-updater (which doesn't need this branch — it'll naturally re-installpnpm).PATH. If they self-update and don't have Node available, the new bin shim will fail at the next invocation — but the alternative (silently leaving them with a broken@pnpm/exe) is strictly worse, and the warning at swap time tells them what's needed. v10@pnpm/exeusers typically already manage Node throughpnpm env use, so this should be uncommon.Compat
currentPkgName === '@pnpm/exe' && process.platform === 'darwin' && process.arch === 'x64' && semver.major(pnpmVersion) >= 11.pnpm self-update 10.x(any v10 patch): no swap, install proceeds as before.pnpm self-update(no version → resolveslatest, currently v11+): swap fires, warning printed, JS pnpm installed.pnpm self-update 11.0.5(explicit v11): swap fires.Test plan
pnpm testfor@pnpm/tools.plugin-commands-self-updater— all 7 existing tests pass (the swap branch isn't triggered because the existing tests mockpackageManageraspnpm@9.0.0).pnpm run spellcheckclean.pnpm run compileclean.PNPM_VERSION=11.0.5 pnpm self-updatefrom a v10@pnpm/exeinstall and confirming it produces a workingpnpmshim.References