From 9928a19d3c17b4a8ffa5bb049c11935dcdfe3a93 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Sun, 16 Nov 2025 01:27:41 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A4=96=20fix:=20make=20node-pty=20reb?= =?UTF-8?q?uild=20conditional=20on=20Electron=20presence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When installing mux via npm as a CLI tool, Electron is not present, causing the postinstall script to fail when trying to rebuild node-pty for Electron ABI. This change makes the rebuild conditional: - If Electron is installed (dev/packaged app): rebuild for Electron ABI - If Electron is not installed (npm CLI): use Node.js ABI (default) This allows mux to be installed both as an Electron app (with terminal support) and as a standalone CLI tool via npm. _Generated with `mux`_ --- package.json | 3 ++- scripts/postinstall.sh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 scripts/postinstall.sh diff --git a/package.json b/package.json index 0294c8c32..fad058905 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "access": "public" }, "scripts": { - "postinstall": "npx @electron/rebuild -f -m node_modules/node-pty", + "postinstall": "./scripts/postinstall.sh", "dev": "make dev", "prebuild:main": "./scripts/generate-version.sh", "build": "make build", @@ -171,6 +171,7 @@ "dist/**/*.json", "dist/**/*.png", "dist/assets/**/*", + "scripts/postinstall.sh", "README.md", "LICENSE" ], diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh new file mode 100755 index 000000000..29846de82 --- /dev/null +++ b/scripts/postinstall.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Only rebuild node-pty for Electron if Electron is installed (for dev or packaged app usage) +# For npm CLI installs, node-pty will use its default Node.js ABI which works fine +if [ -d "node_modules/electron" ]; then + echo "Electron detected - rebuilding node-pty for Electron ABI..." + + # Use bun x or npx depending on what's available + if command -v bun &>/dev/null; then + bun x @electron/rebuild -f -m node_modules/node-pty + elif command -v npx &>/dev/null; then + npx @electron/rebuild -f -m node_modules/node-pty + else + echo "Warning: Neither bun nor npx found, skipping rebuild" + echo "node-pty may not work correctly in Electron" + fi +else + echo "Electron not detected - using node-pty with Node.js ABI (CLI mode)" +fi From 17eb7125f2a8033e8ae7e4e072a3859e52db0220 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Sun, 16 Nov 2025 07:20:39 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A4=96=20fix:=20use=20prebuilt=20node?= =?UTF-8?q?-pty=20to=20avoid=20build=20requirements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace node-pty with @homebridge/node-pty-prebuilt-multiarch which includes prebuilt binaries for common platforms (Linux, macOS, Windows). This allows mux to be installed on servers without requiring build tools (python3, node-gyp, make, g++). The prebuilt package is API-compatible with node-pty and works with both Node.js and Electron. Fixes the error: node-pty [1/2] > Copying prebuilds to release folder... SKIPPED Prebuild directory does not exist /usr/bin/bash: line 1: node-gyp: command not found error: install script from "node-pty" exited with 127 _Generated with `mux`_ --- package.json | 2 +- src/services/ptyService.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index fad058905..38df9e313 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "minimist": "^1.2.8", "motion": "^12.23.24", "ollama-ai-provider-v2": "^1.5.4", - "node-pty": "1.1.0-beta39", + "@homebridge/node-pty-prebuilt-multiarch": "^0.11.14", "rehype-harden": "^1.1.5", "shescape": "^2.1.6", "source-map-support": "^0.5.21", diff --git a/src/services/ptyService.ts b/src/services/ptyService.ts index 6a7e91567..bc5273ba8 100644 --- a/src/services/ptyService.ts +++ b/src/services/ptyService.ts @@ -8,7 +8,7 @@ import { log } from "@/services/log"; import type { Runtime } from "@/runtime/Runtime"; import type { TerminalSession, TerminalCreateParams, TerminalResizeParams } from "@/types/terminal"; -import type { IPty } from "node-pty"; +import type { IPty } from "@homebridge/node-pty-prebuilt-multiarch"; import { SSHRuntime, type SSHRuntimeConfig } from "@/runtime/SSHRuntime"; import { LocalRuntime } from "@/runtime/LocalRuntime"; import { access } from "fs/promises"; @@ -98,10 +98,10 @@ export class PTYService { if (runtime instanceof LocalRuntime) { // Local: Use node-pty (dynamically import to avoid crash if not available) // eslint-disable-next-line @typescript-eslint/consistent-type-imports - let pty: typeof import("node-pty"); + let pty: typeof import("@homebridge/node-pty-prebuilt-multiarch"); try { // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment - pty = require("node-pty"); + pty = require("@homebridge/node-pty-prebuilt-multiarch"); } catch (err) { log.error("node-pty not available - local terminals will not work:", err); throw new Error( @@ -206,10 +206,10 @@ export class PTYService { // Load node-pty dynamically // eslint-disable-next-line @typescript-eslint/consistent-type-imports - let pty: typeof import("node-pty"); + let pty: typeof import("@homebridge/node-pty-prebuilt-multiarch"); try { // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment - pty = require("node-pty"); + pty = require("@homebridge/node-pty-prebuilt-multiarch"); } catch (err) { log.error("node-pty not available - SSH terminals will not work:", err); throw new Error( From baa421896b258469a943c6665ecddf4c0044c336 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Sun, 16 Nov 2025 07:57:06 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=A4=96=20fix:=20remove=20postinstall?= =?UTF-8?q?=20script=20for=20prebuilt=20node-pty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The @homebridge/node-pty-prebuilt-multiarch package includes prebuilt binaries for both Node.js and Electron, so no rebuild is needed during installation. This simplifies the install process and removes the need for the postinstall script. _Generated with `mux`_ --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 38df9e313..ce3232155 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "access": "public" }, "scripts": { - "postinstall": "./scripts/postinstall.sh", "dev": "make dev", "prebuild:main": "./scripts/generate-version.sh", "build": "make build", From 81cbe300347d5433ae84eb711ccc02bb7b224b77 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Sun, 16 Nov 2025 07:59:43 +0000 Subject: [PATCH 4/4] rm postinstall --- scripts/postinstall.sh | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 scripts/postinstall.sh diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh deleted file mode 100755 index 29846de82..000000000 --- a/scripts/postinstall.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Only rebuild node-pty for Electron if Electron is installed (for dev or packaged app usage) -# For npm CLI installs, node-pty will use its default Node.js ABI which works fine -if [ -d "node_modules/electron" ]; then - echo "Electron detected - rebuilding node-pty for Electron ABI..." - - # Use bun x or npx depending on what's available - if command -v bun &>/dev/null; then - bun x @electron/rebuild -f -m node_modules/node-pty - elif command -v npx &>/dev/null; then - npx @electron/rebuild -f -m node_modules/node-pty - else - echo "Warning: Neither bun nor npx found, skipping rebuild" - echo "node-pty may not work correctly in Electron" - fi -else - echo "Electron not detected - using node-pty with Node.js ABI (CLI mode)" -fi