fix(pty): switch to @homebridge/node-pty-prebuilt-multiarch fork
Resolves "Failed to load PTY module" install errors on Linux/macOS by aliasing node-pty to the homebridge fork, which ships prebuilds for linux x64/arm64/arm/ia32 across many Node ABIs and uses prebuild-install for darwin/windows binaries on install. - Aliased dep so all "node-pty" import specifiers (and vi.mock calls) keep working unchanged. - Removed darwin chmod postinstall hack (fork handles permissions). - Updated cli/build.ts to dynamically resolve node-pty install root and pick prebuilds by ABI for Linux cross-compile; warn-and-skip for darwin/windows cross-compile (host-only there, as before). - Added type shim because the fork's bundled typings declare module '@homebridge/node-pty-prebuilt-multiarch', not 'node-pty'. Verified: pnpm install clean, dashboard typecheck clean, native module loads and spawns shell via fork, host + linux-x64 cross-compile staging both produce dist/runtime/<plat>/pty.node. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -170,11 +170,15 @@ dist/
|
||||
**Important:** When distributing or moving the binary, ensure the `client/` and `runtime/` directories are copied alongside it. Terminal functionality will gracefully degrade (return HTTP 503) if runtime assets are missing — the dashboard will continue to work but terminal sessions won't be available.
|
||||
|
||||
**How it works:**
|
||||
When the dashboard starts from a Bun-compiled binary, it attempts to set up native module resolution so `node-pty` can find its platform-specific `.node` files. This involves:
|
||||
1. Copying native assets to a temp directory (`/tmp/kb-bunfs-<pid>/kb/prebuilds/<platform>/`)
|
||||
When the dashboard starts from a Bun-compiled binary, it attempts to set up native module resolution so `@homebridge/node-pty-prebuilt-multiarch` (aliased as `node-pty`) can find its platform-specific `.node` file. This involves:
|
||||
1. Copying the staged `pty.node` from `runtime/<platform>/` to a temp directory (`/tmp/fn-bunfs-<pid>/fn/prebuilds/<platform>/`)
|
||||
2. Attempting to create a symlink at `/$bunfs/root` pointing to the temp directory (Unix platforms)
|
||||
3. If the symlink can't be created (e.g., macOS permissions), pre-loading the native module via `process.dlopen()`
|
||||
|
||||
During the build (`bun run build.ts`), native assets are sourced from:
|
||||
- **Host platform**: `node_modules/node-pty/build/Release/pty.node` (placed by `prebuild-install` at install time)
|
||||
- **Linux cross-compile targets**: `node_modules/node-pty/prebuilds/linux-<arch>/node.abi<N>.node` (bundled in the fork's npm tarball)
|
||||
|
||||
If all resolution methods fail, terminal creation gracefully returns `null`, which the HTTP layer converts to a 503 Service Unavailable response.
|
||||
|
||||
**Cross-compilation:** Native assets are staged per-platform during build. When cross-compiling, only the target platform's assets are included. PTY functionality requires running on a platform with matching native assets.
|
||||
|
||||
Reference in New Issue
Block a user