Skip to content

Commit d50ceee

Browse files
committed
fix: restore macOS node-pty helper permissions
1 parent 678ee56 commit d50ceee

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145
"serve": "npm run build && node bin/crewcode-server.mjs serve",
146146
"prepack": "npm run build",
147147
"typecheck": "tsc -p tsconfig.node.json --noEmit && tsc -p tsconfig.web.json --noEmit && tsc -p packages/crewcode-plugin-api/tsconfig.json --noEmit",
148-
"rebuild": "electron-rebuild -f -o node-pty",
148+
"rebuild": "electron-rebuild -f -o node-pty && npm run fix-node-pty-permissions",
149+
"fix-node-pty-permissions": "node scripts/fix-node-pty-permissions.mjs",
150+
"postinstall": "npm run fix-node-pty-permissions",
149151
"install-electron": "node node_modules/electron/install.js",
150152
"sync-plugin-api": "node scripts/sync-plugin-api-helper.mjs",
151153
"crewcode": "node packages/crewcode-plugin-cli/bin/crewcode.mjs",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
// node-pty 1.1.0's npm tarball ships the macOS spawn-helper files without the
3+
// executable bit. Its native addon invokes this helper through posix_spawnp, so
4+
// terminals fail with the otherwise opaque "posix_spawnp failed" error until
5+
// the mode is restored. Keep this local workaround until node-pty ships the
6+
// helpers as executables.
7+
import { chmodSync, existsSync, readdirSync } from 'node:fs'
8+
import { join } from 'node:path'
9+
10+
if (process.platform !== 'win32') {
11+
const nodePtyRoot = join(process.cwd(), 'node_modules', 'node-pty')
12+
const candidates = [join(nodePtyRoot, 'build', 'Release', 'spawn-helper')]
13+
const prebuilds = join(nodePtyRoot, 'prebuilds')
14+
15+
if (existsSync(prebuilds)) {
16+
for (const directory of readdirSync(prebuilds)) {
17+
if (directory.startsWith('darwin-')) candidates.push(join(prebuilds, directory, 'spawn-helper'))
18+
}
19+
}
20+
21+
for (const helper of candidates) {
22+
if (existsSync(helper)) chmodSync(helper, 0o755)
23+
}
24+
}

0 commit comments

Comments
 (0)