Skip to content

fix(release): rebuild node-pty per target arch on macOS (closes #45)#56

Merged
Ron537 merged 1 commit into
mainfrom
fix/intel-mac-arm64-pty-bundling
May 11, 2026
Merged

fix(release): rebuild node-pty per target arch on macOS (closes #45)#56
Ron537 merged 1 commit into
mainfrom
fix/intel-mac-arm64-pty-bundling

Conversation

@Ron537
Copy link
Copy Markdown
Owner

@Ron537 Ron537 commented May 11, 2026

Fixes #45.

Summary

The v0.13.0 / v0.14.0 DPlex-x64.dmg is non-functional on every Intel Mac: opening a session fails with [Failed to start terminal], and the main-process log shows posix_spawnp failed from node-pty.

Root cause

electron-builder.yml had npmRebuild: false, which disables electron-builder's per-arch native-module rebuild step during packaging. With that flag off, the build process packages whatever node_modules/node-pty/build/Release/ happens to contain on the build host — and since our postinstall runs electron-builder install-app-deps once for the host arch, that directory only ever has binaries for the runner's arch (arm64 on macos-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) probes build/Release/build/Debug/prebuilds/<plat>-<arch>/, so the stray host-arch build/Release/ wins over the per-arch prebuilds at runtime.

Fix

Remove npmRebuild: false. true is the default; with it enabled, electron-builder runs @electron/rebuild per target arch (clang on macOS cross-compiles x86_64 from Apple Silicon out of the box), so each arch's .app ships with the correct pty.node and spawn-helper. A comment in electron-builder.yml documents why this must stay enabled.

Alternatives considered and rejected

  • Excluding build/** and falling back to the npm-shipped prebuilds/: tempting but the prebuilt spawn-helper ships with mode 0644. Confirmed locally that with only prebuilds present, posix_spawn fails with EACCES — same surface error as the arch-mismatch bug. Would have needed an afterPack chmod, i.e. binary fiddling.
  • Universal .dmg: doubles download size and still needs per-arch rebuild internally.
  • Per-runner split (macos-13 for Intel): GitHub is retiring Intel macOS runners; cross-compile from a single arm64 runner is the future-proof path.
  • afterPack verification script: ~150 lines of CI surface to catch one regression class that's already documented inline in electron-builder.yml and visible in any PR diff. Not worth the maintenance.

Pre-release verification

Recommended before tagging v0.14.1:

gh workflow run release.yml -f dry-run=true
gh run download --name dplex-macos-latest
hdiutil attach DPlex-x64.dmg
file "/Volumes/DPlex"*/DPlex.app/Contents/Resources/app.asar.unpacked/node_modules/node-pty/build/Release/spawn-helper
# Expect: Mach-O 64-bit executable x86_64
hdiutil detach "/Volumes/DPlex"*

Test plan

  • npm run lint — no new issues
  • npm run typecheck — clean
  • npm run test:unit — 325/325 pass
  • Manual verification of the produced DPlex-x64.dmg on an Intel Mac (or via file inspection 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.

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>
@Ron537 Ron537 merged commit ab6be49 into main May 11, 2026
5 checks passed
@Ron537 Ron537 deleted the fix/intel-mac-arm64-pty-bundling branch May 11, 2026 08:56
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.

macOS Intel: DPlex-x64.dmg ships arm64 native binaries — every PTY spawn fails with posix_spawnp failed

1 participant