fix(desktop): restore exec bit on node-pty spawn-helper for dev terminals - #66734
Merged
Merged
Conversation
…nals node-pty's published npm tarball ships the POSIX `spawn-helper` with mode 0644 (no exec bit). node-pty `posix_spawnp`s that helper on macOS/Linux, so a non-executable copy fails every embedded-terminal spawn with `Error: posix_spawnp failed.`. Packaged builds are unaffected because stage-native-deps.mjs chmods the staged copy, but the dev flow (`npm run dev` -> `electron .`) resolves node-pty straight from node_modules, which nothing chmods -- so the first terminal in dev always dies. Restore the exec bit once, lazily, right before the first spawn, via a small DI-testable helper. Idempotent: already-executable copies (packaged builds) are left untouched, and stat/chmod failures are collected and logged rather than thrown so terminal startup never breaks.
OutThisLife
enabled auto-merge
July 18, 2026 05:03
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…awn-helper-exec-bit fix(desktop): restore exec bit on node-pty spawn-helper for dev terminals
This was referenced Aug 3, 2026
This was referenced Aug 3, 2026
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…awn-helper-exec-bit fix(desktop): restore exec bit on node-pty spawn-helper for dev terminals
prmartinow
pushed a commit
to prmartinow/hermes-agent
that referenced
this pull request
Aug 26, 2026
…awn-helper-exec-bit fix(desktop): restore exec bit on node-pty spawn-helper for dev terminals
melon-xf
added a commit
to melon-xf/hermes-agent
that referenced
this pull request
Sep 3, 2026
…awn-helper-exec-bit fix(desktop): restore exec bit on node-pty spawn-helper for dev terminals
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
The embedded terminal in Hermes Desktop crashes on first use in the dev flow with:
Root cause: node-pty's published npm tarball ships the POSIX
spawn-helperwith mode0644(no exec bit) — verified against the upstream tarball:node-pty
posix_spawnps that helper on macOS/Linux, so a non-executable copy fails every terminal spawn. This reproduces from plain Node too, not just Electron.Why it only bites in dev:
stage-native-deps.mjscopies the helper intodist/andmakeExecutable()s it (chmod 755).bundle-electron-main.mjs --devmarksnode-ptyexternal, soelectron .resolvesrequire('node-pty')from the rawnode_modules/node-pty, which nothing ever chmods. Every macOS/Linux dev runningnpm run devhits this on the first terminal.Fix
apps/desktop/electron/spawn-helper-perms.tsthat scans a node-pty package root (prebuilds/*+build/Release) and restores exec bits on anyspawn-helperthat's missing them. Best-effort: missing files are skipped; stat/chmod failures are collected and logged, never thrown.main.tsas a memoized guard invoked right before the firsthermes:terminal:startspawn. Packaged builds already stage a0755copy, so it's a no-op there; Windows (nospawn-helper) short-circuits.Single-resolver, single home for the policy — no build-step coupling, and it also self-heals any environment where the bit got stripped.
Test plan
npx vitest run electron/spawn-helper-perms.test.ts— 6 tests, covers exec-bit detection, candidate discovery, selective chmod, missing files, chmod-failure collection, and the Windows no-op.npm run typecheckclean.npx eslintclean on changed files.node scripts/bundle-electron-main.mjs --devbuilds.spawn-helperto0644, confirmedrequire.resolve('node-pty/package.json')resolves the same copy the app uses, the guard restores0755, andnode-ptyspawns successfully.