Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(installer): build node-pty reliably on Codespaces

Abdurrahman Fakhrul527fde690de4
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 21e6d27e..f5a4d894 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `installer` build node-pty reliably on Codespaces
- `managed-apps` support Hermes without systemd
## 2026-09-16
diff --git a/scripts/install-core.sh b/scripts/install-core.sh
index 1925a194..c50a05f4 100755
--- a/scripts/install-core.sh
+++ b/scripts/install-core.sh
@@ -285,15 +285,24 @@ ensure_bun() {
}
ensure_buildtools() {
- # node-pty is a native addon with no linux prebuild → needs a C/C++ toolchain +
- # python3 to compile at install time, under bun exactly as under pnpm.
- # This is the single most likely install failure on a minimal box.
- command -v cc >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1 && return
+ # node-pty is a native addon with no Linux prebuild for every Node ABI. A host
+ # can have `cc` + Python (GitHub Codespaces does) while still missing `c++` or
+ # `make`, so validate the complete native toolchain instead of short-circuiting.
+ local missing=0 tool
+ for tool in cc c++ make python3; do
+ command -v "$tool" >/dev/null 2>&1 || { missing=1; break; }
+ done
+ [ "$missing" -eq 0 ] && return
+
info "installing build toolchain (for node-pty)…"
if command -v apt-get >/dev/null 2>&1; then sudo_do apt-get update -qq && sudo_do apt-get install -y -qq build-essential python3
elif command -v dnf >/dev/null 2>&1; then sudo_do dnf install -y -q gcc-c++ make python3
elif command -v pacman >/dev/null 2>&1; then sudo_do pacman -Sy --noconfirm base-devel python
- else warn "no known package manager — if 'bun install' fails on node-pty, install a C++ toolchain + python3 by hand."; fi
+ else warn "no known package manager — node-pty needs a C/C++ compiler, make and python3."; fi
+
+ for tool in cc c++ make python3; do
+ command -v "$tool" >/dev/null 2>&1 || die "native build dependency still missing: $tool"
+ done
}
ensure_cli_tools() {
diff --git a/scripts/install.sh b/scripts/install.sh
index b8e012fa..66333de4 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -12,7 +12,7 @@ set -Eeuo pipefail
umask 077
CORE_URL="${MSO_INSTALL_CORE_URL:-https://raw.githubusercontent.com/rahmanef63/mso/main/scripts/install-core.sh}"
-CORE_SHA256="857e5c2571a8d83abce5687366c54515608af5c72c325d6e380e9b53cef044a0"
+CORE_SHA256="480f13d75d04293560fe8eef1048d0b0c764767890e4b3b6f95e704b80a01388"
CORE_EOF='# MSO_INSTALLER_CORE_EOF'
TMP_INSTALLER=''
diff --git a/scripts/install/runtime-build.sh b/scripts/install/runtime-build.sh
index 2e0c66b1..efa1eba8 100755
--- a/scripts/install/runtime-build.sh
+++ b/scripts/install/runtime-build.sh
@@ -13,10 +13,46 @@ install_runtime_lifecycle_begin
INSTALL_PHASE=dependencies
# ---- deps (compiles node-pty) ----
+# [email protected] falls back to the `node-gyp` command when no Linux prebuild is
+# available. Minimal/Codespaces images can have a complete compiler toolchain but
+# no standalone node-gyp binary. Provide a pinned user-local runner before Bun
+# executes dependency lifecycle scripts; do not mutate global npm state.
+NODE_GYP_VERSION="11.5.0"
+NODE_GYP_PREFIX="${MSO_NODE_GYP_PREFIX:-$HOME/.cache/mso/node-gyp-$NODE_GYP_VERSION}"
+NODE_GYP_BIN="$NODE_GYP_PREFIX/node_modules/.bin/node-gyp"
+
+ensure_node_gyp_runner() {
+ if [ -x "$NODE_GYP_BIN" ] && [ "$("$NODE_GYP_BIN" --version 2>/dev/null || true)" = "v$NODE_GYP_VERSION" ]; then
+ export PATH="$(dirname "$NODE_GYP_BIN"):$PATH"
+ return
+ fi
+ command -v npm >/dev/null 2>&1 || die "npm is required to provision pinned node-gyp for node-pty."
+ mkdir -p "$NODE_GYP_PREFIX"
+ info "provisioning node-gyp v$NODE_GYP_VERSION for node-pty…"
+ npm install --prefix "$NODE_GYP_PREFIX" --no-save --ignore-scripts "node-gyp@$NODE_GYP_VERSION" >/dev/null
+ [ -x "$NODE_GYP_BIN" ] || die "node-gyp bootstrap did not produce $NODE_GYP_BIN"
+ [ "$("$NODE_GYP_BIN" --version 2>/dev/null || true)" = "v$NODE_GYP_VERSION" ] || die "unexpected node-gyp version after bootstrap"
+ export PATH="$(dirname "$NODE_GYP_BIN"):$PATH"
+}
+
+node_pty_ready() {
+ node -e 'require("node-pty")' >/dev/null 2>&1
+}
+
+ensure_node_gyp_runner
info "installing dependencies…"
install_runtime_lifecycle_mark_mutation_started
bun install --frozen-lockfile || bun install
+# A package-manager retry may report "no changes" after a failed lifecycle
+# script. Verify the native binding immediately so Next.js cannot fail much later
+# while collecting route configuration. One explicit rebuild is safe/idempotent.
+if ! node_pty_ready; then
+ warn "node-pty native binding missing after dependency install — rebuilding once…"
+ "$NODE_GYP_BIN" rebuild --directory="$DIR/node_modules/node-pty"
+fi
+node_pty_ready || die "node-pty native binding is still unavailable after rebuild."
+
INSTALL_PHASE=configuration
# ---- data dir + secrets (write .env.local only if absent) ----
mkdir -p "$HOME/.mso" && chmod 700 "$HOME/.mso"