Skip to content

Commit 2a37123

Browse files
committed
fix(terminal): add postinstall chmod for node-pty spawn-helper on macOS
Workaround for node-pty #850: the prebuilt spawn-helper binary ships without execute permissions in the npm tarball, causing PTY spawns to fail with EACCES on macOS CI. This postinstall script ensures +x is set after npm install. Remove once node-pty >=1.2.0 is available.
1 parent d6250a4 commit 2a37123

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

src-node/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"homepage": "https://github.com/phcode-dev/phoenix",
99
"license": "GNU-AGPL3.0",
1010
"scripts": {
11+
"postinstall": "node postinstall.js",
1112
"_watch_src-node": "cd .. && npm run _watch_src-node"
1213
},
1314
"engines": {

src-node/postinstall.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
// Workaround for node-pty #850: spawn-helper ships without +x in npm tarball.
5+
// Fixed in node-pty >=1.2.0; remove this script once we upgrade.
6+
if (process.platform === "darwin") {
7+
const candidates = ["darwin-arm64", "darwin-x64"];
8+
for (const dir of candidates) {
9+
const helperPath = path.join(
10+
__dirname, "node_modules", "node-pty",
11+
"prebuilds", dir, "spawn-helper"
12+
);
13+
try {
14+
fs.chmodSync(helperPath, 0o755);
15+
console.log(`postinstall: chmod 755 ${helperPath}`);
16+
} catch (e) {
17+
if (e.code === "ENOENT") {
18+
console.log(`postinstall: spawn-helper not found for ${dir} (expected on other arch)`);
19+
} else {
20+
console.error(`postinstall: failed to chmod spawn-helper for ${dir}: ${e.message}`);
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)