fix(desktop): rebuild node-pty for Electron when no prebuild covers the target - #63391
seojacknet-ops wants to merge 1 commit into
Conversation
…he target
node-pty publishes no linux prebuild, and its compile-on-install script was
blocked by allowScripts — so Linux packs shipped without pty.node and the
packaged app crashed on launch ("Failed to load native module: pty.node").
Even with the script approved, npm builds against the host Node ABI, which
Electron refuses to load.
- add scripts/ensure-node-pty-electron.mjs: before staging, rebuild node-pty
via @electron/rebuild when there is no published prebuild for the host
target and no stamp-verified Electron-ABI build; no-op otherwise
- wire it into the desktop "build" script ahead of stage-native-deps
- approve node-pty's install script in the workspace allowScripts
- stage-native-deps: only warn about a missing prebuild when build/Release
has no pty.node either
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Related to #61798 (competing fix for the same verified Linux node-pty-missing desktop crash), and issues #62171 (bug spec) / #62462 (dup report). Different mechanism: #61798 makes @electron/rebuild traverse the npm workspace root and adds a launcher completeness gate; this PR adds a dedicated pre-stage |
|
Thanks for the focused Linux desktop packaging fix. This automated hermes-sweeper review found that the requested behavior is already implemented on current
The related competing fix, #61798, was also closed by its author as superseded after auditing these landed commits. Closing as implemented on main. |
Problem
On Linux, the packaged desktop app crashes at launch:
node-pty publishes prebuilds for darwin/win32 but not linux, and its compile-on-install script is blocked by the workspace
allowScriptspolicy — so Linux packs ship node-pty with no native binary at all.stage-native-deps.mjsalready warns about this, but the build still succeeds and the app crashes at runtime.Even with the install script approved,
node-gyp rebuildcompiles against the host Node ABI, which Electron refuses to load ("compiled against a different Node.js version").Fix
apps/desktop/scripts/ensure-node-pty-electron.mjs, wired into the desktopbuildscript ahead ofstage-native-deps.mjs. It's a no-op when a published prebuild exists for the host platform/arch, or whenbuild/Release/pty.nodewas already rebuilt for the current Electron version (tracked via a stamp file inbuild/Release, so a freshnpm cialways retriggers). Otherwise it runs@electron/rebuild -w node-ptyagainst the workspace's Electron version and fails the build loudly if that doesn't producepty.node.allowScripts.stage-native-deps.mjs: only warn about a missing prebuild whenbuild/Release/pty.nodeis also missing, so healthy Linux builds don't print a scary warning.Verification
ensure-node-pty-electron.mjsrebuilds on first run, no-ops on the second (stamp match).hermes desktoppack on Fedora 44 (linux-x64, Electron 40.10.2):pty.nodelands inapp.asar.unpacked, and the packaged Electron loads node-pty and spawns a PTY successfully.🤖 Generated with Claude Code