fix: automate node-pty rebuild to eliminate terminal issues

- Add postinstall hook to automatically rebuild node-pty after pnpm install
- Create scripts/rebuild-node-pty.js for automatic rebuild with error handling
- Remove manual node-pty rebuild from setup.sh (now automatic)

This ensures DirectTerminal works correctly on every installation without
manual intervention. Fixes posix_spawnp errors from incompatible prebuilt
binaries across different systems and installations.

Resolves issue where users would encounter blank terminals after setup.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Prateek 2026-02-16 15:16:51 +05:30
parent 737b6111e0
commit d08dfda917
3 changed files with 41 additions and 6 deletions

View File

@ -23,7 +23,8 @@
"changeset": "changeset",
"version-packages": "changeset version",
"release": "pnpm -r --filter '!@composio/ao-web' build && changeset publish",
"prepare": "husky"
"prepare": "husky",
"postinstall": "node scripts/rebuild-node-pty.js"
},
"devDependencies": {
"@changesets/cli": "^2.29.8",

View File

@ -0,0 +1,39 @@
#!/usr/bin/env node
// Automatically rebuild node-pty from source after pnpm install
// This fixes DirectTerminal "posix_spawnp failed" errors from incompatible prebuilt binaries
import { execSync } from "node:child_process";
import { existsSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const repoRoot = join(__dirname, "..");
// Find node-pty in pnpm node_modules
const nodePtyPath = join(
repoRoot,
"node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty",
);
if (!existsSync(nodePtyPath)) {
console.log(" node-pty not found, skipping rebuild");
process.exit(0);
}
console.log("🔧 Rebuilding node-pty from source...");
try {
execSync("npx node-gyp rebuild", {
cwd: nodePtyPath,
stdio: "inherit",
});
console.log("✅ node-pty rebuilt successfully");
} catch (error) {
console.warn("⚠️ node-pty rebuild failed (non-critical)");
console.warn(" DirectTerminal may not work correctly");
console.warn(" Run manually: cd node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty && npx node-gyp rebuild");
// Don't fail the install - node-pty rebuild failure is non-critical
process.exit(0);
}

View File

@ -19,11 +19,6 @@ pnpm install
echo "🔨 Building all packages..."
pnpm build
echo "🔧 Rebuilding node-pty from source (fixes DirectTerminal)..."
cd node_modules/.pnpm/node-pty@1.1.0/node_modules/node-pty
npx node-gyp rebuild > /dev/null 2>&1 || echo "⚠️ node-pty rebuild failed (non-critical)"
cd ../../../../..
echo "🔗 Linking CLI globally..."
cd packages/cli
npm link