From db72074e0a92b93dac34ec94c57717b43beeb3a6 Mon Sep 17 00:00:00 2001 From: L <6723574+louisgv@users.noreply.github.com> Date: Thu, 12 Feb 2026 12:13:19 -0800 Subject: [PATCH] fix: fall back to source-mode install when bundled build fails (#707) bun 1.3.8 in Termux proot cannot resolve packages with --packages bundle even with bun.lock present and after --force reinstall. When the bundled build fails, install source + node_modules to ~/.spawn/ and create a wrapper script that runs via `bun` directly. Co-authored-by: Sprite Co-authored-by: Claude Opus 4.6 (1M context) --- cli/install.sh | 31 +++++++++++++++++++++++++++---- cli/package.json | 2 +- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/cli/install.sh b/cli/install.sh index f51fae4d..6149c1df 100755 --- a/cli/install.sh +++ b/cli/install.sh @@ -163,16 +163,39 @@ build_and_install() { cd "${tmpdir}/cli" bun install - if ! bun run build; then + + local build_ok=0 + if bun run build 2>/dev/null; then + build_ok=1 + else log_warn "Build failed, retrying with forced reinstall..." bun install --force - bun run build + if bun run build 2>/dev/null; then + build_ok=1 + fi fi INSTALL_DIR="$(find_install_dir)" mkdir -p "${INSTALL_DIR}" - cp cli.js "${INSTALL_DIR}/spawn" - chmod +x "${INSTALL_DIR}/spawn" + + if [ "$build_ok" = "1" ]; then + cp cli.js "${INSTALL_DIR}/spawn" + chmod +x "${INSTALL_DIR}/spawn" + else + # Bundled build failed — fall back to source mode. + # Install source + node_modules to ~/.spawn/ and create a wrapper. + log_warn "Bundled build unavailable, installing from source..." + local spawn_lib="${HOME}/.spawn" + rm -rf "${spawn_lib}" + mkdir -p "${spawn_lib}" + cp -r node_modules src package.json "${spawn_lib}/" + cat > "${INSTALL_DIR}/spawn" <<'WRAPPER' +#!/usr/bin/env bash +exec bun "$HOME/.spawn/src/index.ts" "$@" +WRAPPER + chmod +x "${INSTALL_DIR}/spawn" + fi + log_info "Installed spawn to ${INSTALL_DIR}/spawn" ensure_in_path "${INSTALL_DIR}" } diff --git a/cli/package.json b/cli/package.json index e02c9c55..f21de999 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/spawn", - "version": "0.2.60", + "version": "0.2.61", "type": "module", "bin": { "spawn": "cli.js"