Fix "posix_spawnp failed" by restoring node-pty spawn-helper execute bit#12
Open
LonestoneBot wants to merge 1 commit into
Open
Fix "posix_spawnp failed" by restoring node-pty spawn-helper execute bit#12LonestoneBot wants to merge 1 commit into
LonestoneBot wants to merge 1 commit into
Conversation
When the plugin is distributed as an unpacked bundle (rather than a fresh
`npm install`), node-pty's native `spawn-helper` binary can lose its execute
permission. On macOS and Linux, node-pty exec's this helper to launch the
shell, so without the +x bit every pty.spawn() fails with:
Error: Failed to spawn shell: posix_spawnp failed
Add ensureSpawnHelperExecutable(), run once at startup after node-pty loads.
It locates the helper in both the prebuilds/<platform-arch>/ and
build/Release/ layouts and restores the execute bit when missing. Best-effort
and no-op on Windows, so it can't regress a working install.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Problem
Opening a terminal fails with:
Root cause
On macOS and Linux, node-pty launches the shell by exec'ing its bundled native
spawn-helperbinary. When the plugin is distributed as an unpacked bundle(rather than a fresh
npm install), the archiving/extraction step can drop theexecute bit on that binary:
Without
+x,posix_spawnpreturnsEACCES, which node-pty surfaces asposix_spawnp failed. Diagnosis on an affected install (Intel macOS,node-pty 1.1.0): the binary is a valid
Mach-O x86_64executable with noGatekeeper quarantine — only the execute bit is missing.
chmod +xon thehelper immediately fixes it.
Fix
Add
ensureSpawnHelperExecutable(), run once at startup right after node-ptyis loaded. It locates the helper in both the modern
prebuilds/<platform-arch>/layout and the legacy
build/Release/layout, and restores the execute bit whenit's missing.
is already set — so it can't regress a healthy install.
findModule,prioritizeUserNpmGlobalBin).Testing
On an affected install:
The helper is restored to
-rwxr-xr-xand terminals spawn normally.tscbuild passes. Onlysrc/server.tschanges (dist/ is gitignored).🤖 Generated with Claude Code