Skip to content

Commit be7198f

Browse files
committed
fix(install): pin git wrapper node runtime
1 parent 42fc19d commit be7198f

2 files changed

Lines changed: 73 additions & 1 deletion

File tree

scripts/install.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2659,10 +2659,26 @@ install_openclaw_from_git() {
26592659

26602660
ensure_user_local_bin_on_path
26612661

2662+
local node_bin="" node_bin_quoted="" entry_path_quoted=""
2663+
node_bin="$(type -P node 2>/dev/null || true)"
2664+
if [[ -n "$node_bin" && "$node_bin" != /* ]]; then
2665+
local node_dir=""
2666+
node_dir="$(cd "$(dirname "$node_bin")" && pwd -P 2>/dev/null)" || node_dir=""
2667+
if [[ -n "$node_dir" ]]; then
2668+
node_bin="${node_dir}/$(basename "$node_bin")"
2669+
fi
2670+
fi
2671+
if [[ -z "$node_bin" || ! -x "$node_bin" ]]; then
2672+
ui_error "Node.js runtime not found after build"
2673+
return 1
2674+
fi
2675+
printf -v node_bin_quoted "%q" "$node_bin"
2676+
printf -v entry_path_quoted "%q" "${repo_dir}/dist/entry.js"
2677+
26622678
cat > "$HOME/.local/bin/openclaw" <<EOF
26632679
#!/usr/bin/env bash
26642680
set -euo pipefail
2665-
exec node "${repo_dir}/dist/entry.js" "\$@"
2681+
exec ${node_bin_quoted} ${entry_path_quoted} "\$@"
26662682
EOF
26672683
chmod +x "$HOME/.local/bin/openclaw"
26682684
ui_success "OpenClaw wrapper installed to \$HOME/.local/bin/openclaw"

test/scripts/install-sh.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,62 @@ describe("install.sh", () => {
8686
expect(result.stdout + result.stderr).toContain("Missing value for --version");
8787
});
8888

89+
it("writes git install wrappers with the resolved Node runtime", () => {
90+
const result = runInstallShell(`
91+
set -euo pipefail
92+
source "${SCRIPT_PATH}"
93+
tmp="$(mktemp -d)"
94+
repo="$tmp/repo"
95+
node_dir="node-bin"
96+
cd "$tmp"
97+
mkdir -p "$repo/.git" "$repo/dist" "$node_dir"
98+
touch "$repo/dist/entry.js"
99+
cat > "$node_dir/node" <<'NODE'
100+
#!/usr/bin/env bash
101+
printf 'fake-node:%s\\n' "$*"
102+
NODE
103+
chmod +x "$node_dir/node"
104+
PATH="$node_dir:/usr/bin:/bin"
105+
export PATH
106+
OS=macos
107+
check_git() { return 0; }
108+
ensure_pnpm() { :; }
109+
ensure_pnpm_binary_for_scripts() { :; }
110+
resolve_git_openclaw_ref() { printf 'main\\n'; }
111+
checkout_git_openclaw_ref() { :; }
112+
cleanup_legacy_submodules() { :; }
113+
activate_repo_pnpm_version() { :; }
114+
git_install_lockfile_flag() { printf '%s\\n' '--frozen-lockfile'; }
115+
run_quiet_step() { return 0; }
116+
ensure_user_local_bin_on_path() {
117+
mkdir -p "$HOME/.local/bin"
118+
export PATH="$HOME/.local/bin:$PATH"
119+
}
120+
ui_info() { :; }
121+
ui_success() { :; }
122+
ui_error() { printf 'error:%s\\n' "$*"; }
123+
git() {
124+
if [[ "$1" == "-C" && "$3" == "status" ]]; then
125+
return 0
126+
fi
127+
printf 'unexpected git:%s\\n' "$*" >&2
128+
return 1
129+
}
130+
131+
install_openclaw_from_git "$repo"
132+
wrapper="$HOME/.local/bin/openclaw"
133+
grep -F "$tmp/$node_dir/node" "$wrapper"
134+
cd /
135+
PATH="/usr/bin:/bin" "$wrapper" --version
136+
`);
137+
138+
expect(result.status).toBe(0);
139+
expect(result.stdout).toContain("exec ");
140+
expect(result.stdout).toContain("/node-bin/node");
141+
expect(result.stdout).toContain("fake-node:");
142+
expect(result.stdout).toContain("/repo/dist/entry.js --version");
143+
});
144+
89145
it("accepts GNU and musl Linux shells in OS detection", () => {
90146
expect(script).toContain('[[ "$OSTYPE" == "linux"* ]]');
91147
expect(script).not.toContain('[[ "$OSTYPE" == "linux-gnu"* ]]');

0 commit comments

Comments
 (0)