fix(install): pin git wrapper node runtime

This commit is contained in:
Vincent Koc
2026-07-04 03:24:07 +02:00
parent 42fc19d77e
commit be7198f6a2
2 changed files with 73 additions and 1 deletions
+17 -1
View File
@@ -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" <<EOF
#!/usr/bin/env bash
set -euo pipefail
exec node "${repo_dir}/dist/entry.js" "\$@"
exec ${node_bin_quoted} ${entry_path_quoted} "\$@"
EOF
chmod +x "$HOME/.local/bin/openclaw"
ui_success "OpenClaw wrapper installed to \$HOME/.local/bin/openclaw"
+56
View File
@@ -86,6 +86,62 @@ describe("install.sh", () => {
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"* ]]');