fix(release): rebuild node-pty per target arch on macOS (closes #45)#56
Merged
Conversation
The previous `npmRebuild: false` setting in electron-builder.yml caused the host runner's host-arch `node_modules/node-pty/build/Release/` to be packaged into every arch's DMG. With the macos-latest runner now being Apple Silicon, that meant the Intel (x64) DMG shipped arm64 native binaries — every PTY spawn on Intel Macs failed with `posix_spawnp failed`, surfacing in the UI as `[Failed to start terminal]`. Removing the override (default is `true`) lets electron-builder run @electron/rebuild per target arch, producing correctly-built native modules for both x64 and arm64 from a single macos-latest runner via clang's built-in cross-compile support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #45.
Summary
The v0.13.0 / v0.14.0
DPlex-x64.dmgis non-functional on every Intel Mac: opening a session fails with[Failed to start terminal], and the main-process log showsposix_spawnp failedfromnode-pty.Root cause
electron-builder.ymlhadnpmRebuild: false, which disables electron-builder's per-arch native-module rebuild step during packaging. With that flag off, the build process packages whatevernode_modules/node-pty/build/Release/happens to contain on the build host — and since ourpostinstallrunselectron-builder install-app-depsonce for the host arch, that directory only ever has binaries for the runner's arch (arm64 onmacos-latest). Those arm64 binaries then get bundled into both the arm64 DMG (correct by coincidence) and the x64 DMG (broken — Intel can't exec arm64).node-pty's native loader (lib/utils.js) probesbuild/Release/→build/Debug/→prebuilds/<plat>-<arch>/, so the stray host-archbuild/Release/wins over the per-arch prebuilds at runtime.Fix
Remove
npmRebuild: false.trueis the default; with it enabled, electron-builder runs@electron/rebuildper target arch (clang on macOS cross-compilesx86_64from Apple Silicon out of the box), so each arch's.appships with the correctpty.nodeandspawn-helper. A comment inelectron-builder.ymldocuments why this must stay enabled.Alternatives considered and rejected
build/**and falling back to the npm-shippedprebuilds/: tempting but the prebuiltspawn-helperships with mode0644. Confirmed locally that with only prebuilds present,posix_spawnfails with EACCES — same surface error as the arch-mismatch bug. Would have needed anafterPackchmod, i.e. binary fiddling..dmg: doubles download size and still needs per-arch rebuild internally.macos-13for Intel): GitHub is retiring Intel macOS runners; cross-compile from a single arm64 runner is the future-proof path.afterPackverification script: ~150 lines of CI surface to catch one regression class that's already documented inline inelectron-builder.ymland visible in any PR diff. Not worth the maintenance.Pre-release verification
Recommended before tagging
v0.14.1:Test plan
npm run lint— no new issuesnpm run typecheck— cleannpm run test:unit— 325/325 passDPlex-x64.dmgon an Intel Mac (or viafileinspection of the packaged binary) before tagging.Diff size
+18 / −2 lines across 3 files. The actual fix is one line; the rest is the explanatory comment + version bump + changelog entry.
Thanks to @raphapizzi for the detailed report and root-cause analysis in #45 — it pointed straight at the right config flag.