From be7198f6a2225dd988e707c4ef11c3cf002c14c3 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 4 Jul 2026 03:24:07 +0200 Subject: [PATCH] fix(install): pin git wrapper node runtime --- scripts/install.sh | 18 ++++++++++- test/scripts/install-sh.test.ts | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 8f1fdd6b1519..0d6cf19584ac 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2659,10 +2659,26 @@ install_openclaw_from_git() { ensure_user_local_bin_on_path + local node_bin="" node_bin_quoted="" entry_path_quoted="" + node_bin="$(type -P node 2>/dev/null || true)" + if [[ -n "$node_bin" && "$node_bin" != /* ]]; then + local node_dir="" + node_dir="$(cd "$(dirname "$node_bin")" && pwd -P 2>/dev/null)" || node_dir="" + if [[ -n "$node_dir" ]]; then + node_bin="${node_dir}/$(basename "$node_bin")" + fi + fi + if [[ -z "$node_bin" || ! -x "$node_bin" ]]; then + ui_error "Node.js runtime not found after build" + return 1 + fi + printf -v node_bin_quoted "%q" "$node_bin" + printf -v entry_path_quoted "%q" "${repo_dir}/dist/entry.js" + cat > "$HOME/.local/bin/openclaw" < { expect(result.stdout + result.stderr).toContain("Missing value for --version"); }); + it("writes git install wrappers with the resolved Node runtime", () => { + const result = runInstallShell(` + set -euo pipefail + source "${SCRIPT_PATH}" + tmp="$(mktemp -d)" + repo="$tmp/repo" + node_dir="node-bin" + cd "$tmp" + mkdir -p "$repo/.git" "$repo/dist" "$node_dir" + touch "$repo/dist/entry.js" + cat > "$node_dir/node" <<'NODE' +#!/usr/bin/env bash +printf 'fake-node:%s\\n' "$*" +NODE + chmod +x "$node_dir/node" + PATH="$node_dir:/usr/bin:/bin" + export PATH + OS=macos + check_git() { return 0; } + ensure_pnpm() { :; } + ensure_pnpm_binary_for_scripts() { :; } + resolve_git_openclaw_ref() { printf 'main\\n'; } + checkout_git_openclaw_ref() { :; } + cleanup_legacy_submodules() { :; } + activate_repo_pnpm_version() { :; } + git_install_lockfile_flag() { printf '%s\\n' '--frozen-lockfile'; } + run_quiet_step() { return 0; } + ensure_user_local_bin_on_path() { + mkdir -p "$HOME/.local/bin" + export PATH="$HOME/.local/bin:$PATH" + } + ui_info() { :; } + ui_success() { :; } + ui_error() { printf 'error:%s\\n' "$*"; } + git() { + if [[ "$1" == "-C" && "$3" == "status" ]]; then + return 0 + fi + printf 'unexpected git:%s\\n' "$*" >&2 + return 1 + } + + install_openclaw_from_git "$repo" + wrapper="$HOME/.local/bin/openclaw" + grep -F "$tmp/$node_dir/node" "$wrapper" + cd / + PATH="/usr/bin:/bin" "$wrapper" --version + `); + + expect(result.status).toBe(0); + expect(result.stdout).toContain("exec "); + expect(result.stdout).toContain("/node-bin/node"); + expect(result.stdout).toContain("fake-node:"); + expect(result.stdout).toContain("/repo/dist/entry.js --version"); + }); + it("accepts GNU and musl Linux shells in OS detection", () => { expect(script).toContain('[[ "$OSTYPE" == "linux"* ]]'); expect(script).not.toContain('[[ "$OSTYPE" == "linux-gnu"* ]]');