fix: make postinstall spawn-helper chmod work under pnpm GVS - #8
Merged
Merged
Conversation
The previous shell-based postinstall used a relative path (`node_modules/node-pty/prebuilds/*/spawn-helper`) that only resolves in flat node_modules layouts. Under pnpm's content-addressed store (especially with enableGlobalVirtualStore), node-pty is a sibling link and the chmod silently no-ops via `2>/dev/null || true`. The result is a non-executable spawn-helper and `posix_spawnp failed` at runtime. Replace with a node script using createRequire from this package's own package.json so it finds node-pty regardless of layout. Also add `scripts/postinstall.js` to the published `files` so the script ships in the tarball. The fundamental fix belongs in microsoft/node-pty (PR filed separately); this is the wrapper-side workaround until that lands. Refs compoundingtech#6 compoundingtech#7
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 current
postinstallworkaround silently no-ops under pnpm withenableGlobalVirtualStore, leavingnode-pty'sspawn-helpernon-executable and causingposix_spawnp failedat runtime.Repro
Root cause
The existing
postinstall:uses a relative path that only resolves in flat
node_moduleslayouts. Under pnpm's content-addressed store (especially withenableGlobalVirtualStore),@myobie/pty's lifecycle CWD is~/Library/pnpm/store/v11/links/@myobie/pty/0.4.1/<hash>/node_modules/@myobie/pty/, andnode-ptylives in a sibling content-addressed link — not nested. The relativenode_modules/node-pty/...path doesn't exist there. The chmod fails,2>/dev/null || trueswallows the error, and the user is left with a non-executable binary.The root cause is in
node-ptyitself (its published tarball shipsspawn-helperwith mode 0644 and its own post-install never chmods it). The fix is already merged upstream in microsoft/node-pty#858 and #866, butnode-pty@1.1.0(the latest published) predates those merges. So this@myobie/ptyworkaround needs to actually work until a newer node-pty ships.The fix
Replace the broken shell
chmodwithscripts/postinstall.js:createRequire(import.meta.url)anchored at this package's own location, thenrequire.resolve('node-pty/package.json')to findnode-ptyregardless of layout.chmod 0755the platform-specificspawn-helper(Linux + macOS).node-gypproduce executable binaries directly)."type": "module"inpackage.json).Also added
scripts/to the publishedfilesarray — without this, the script doesn't end up in the tarball.Validation
End-to-end tested locally:
npm packto produce a tarballenableGlobalVirtualStore: truefind ~/Library/pnpm -name spawn-helper | xargs ls -lshows0755Session.spawn('echo', ['hi'])works withoutposix_spawnp failedchmodexits 1, swallowed by|| true)Future
Once a new
node-ptyrelease ships with the upstream chmod fix (microsoft/node-pty#858, #866), thisscripts/postinstall.jscan be deleted entirely —@myobie/ptywon't need its own workaround anymore.Context
I'm building
@overeng/pty-effect, an Effect-native wrapper around@myobie/pty, and discovered this while validating against my test suite. Related upstream conversations:./clientsubpath exportsEventFollowershippingFiled on behalf of @schickling.