Skip to content

Commit ababcb3

Browse files
cvclaude
andcommitted
fix: enforce full semver >=22.16.0 in installer scripts
The runtime checks only compared the major Node.js version, allowing 22.0–22.15 to pass despite package.json requiring >=22.16.0. Use the version_gte() helper for full semver comparison in both installers. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent d340143 commit ababcb3

3 files changed

Lines changed: 33 additions & 21 deletions

File tree

‎install.sh‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ spin() {
187187

188188
command_exists() { command -v "$1" &>/dev/null; }
189189

190-
MIN_NODE_MAJOR=22
190+
MIN_NODE_VERSION="22.16.0"
191191
MIN_NPM_MAJOR=10
192-
RECOMMENDED_NODE_MAJOR=22
193-
RUNTIME_REQUIREMENT_MSG="NemoClaw requires Node.js >=${MIN_NODE_MAJOR} and npm >=${MIN_NPM_MAJOR}."
192+
RUNTIME_REQUIREMENT_MSG="NemoClaw requires Node.js >=${MIN_NODE_VERSION} and npm >=${MIN_NPM_MAJOR}."
194193
NEMOCLAW_SHIM_DIR="${HOME}/.local/bin"
195194
ORIGINAL_PATH="${PATH:-}"
196195

@@ -274,7 +273,7 @@ ensure_supported_runtime() {
274273
[[ "$node_major" =~ ^[0-9]+$ ]] || error "Could not determine Node.js version from '${node_version}'. ${RUNTIME_REQUIREMENT_MSG}"
275274
[[ "$npm_major" =~ ^[0-9]+$ ]] || error "Could not determine npm version from '${npm_version}'. ${RUNTIME_REQUIREMENT_MSG}"
276275

277-
if ((node_major < MIN_NODE_MAJOR || npm_major < MIN_NPM_MAJOR)); then
276+
if ! version_gte "${node_version#v}" "$MIN_NODE_VERSION" || ((npm_major < MIN_NPM_MAJOR)); then
278277
error "Unsupported runtime detected: Node.js ${node_version:-unknown}, npm ${npm_version:-unknown}. ${RUNTIME_REQUIREMENT_MSG} Upgrade Node.js and rerun the installer."
279278
fi
280279

@@ -318,9 +317,9 @@ install_nodejs() {
318317
spin "Installing nvm..." bash "$nvm_tmp"
319318
rm -f "$nvm_tmp"
320319
ensure_nvm_loaded
321-
spin "Installing Node.js ${RECOMMENDED_NODE_MAJOR}..." bash -c ". \"$NVM_DIR/nvm.sh\" && nvm install ${RECOMMENDED_NODE_MAJOR} --no-progress"
320+
spin "Installing Node.js 22..." bash -c ". \"$NVM_DIR/nvm.sh\" && nvm install 22 --no-progress"
322321
ensure_nvm_loaded
323-
nvm use "${RECOMMENDED_NODE_MAJOR}" --silent
322+
nvm use 22 --silent
324323
info "Node.js installed: $(node --version)"
325324
}
326325

‎scripts/install.sh‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ refresh_path() {
126126
fi
127127
}
128128

129-
MIN_NODE_MAJOR=22
129+
MIN_NODE_VERSION="22.16.0"
130130
MIN_NPM_MAJOR=10
131-
RUNTIME_REQUIREMENT_MSG="NemoClaw requires Node.js >=${MIN_NODE_MAJOR} and npm >=${MIN_NPM_MAJOR}."
131+
RUNTIME_REQUIREMENT_MSG="NemoClaw requires Node.js >=${MIN_NODE_VERSION} and npm >=${MIN_NPM_MAJOR}."
132132

133133
OS="$(uname -s)"
134134
ARCH="$(uname -m)"
@@ -169,6 +169,19 @@ fi
169169

170170
info "Node.js manager: $NODE_MGR"
171171

172+
# Compare two semver strings (major.minor.patch). Returns 0 if $1 >= $2.
173+
version_gte() {
174+
local -a a b
175+
IFS=. read -ra a <<<"$1"
176+
IFS=. read -ra b <<<"$2"
177+
for i in 0 1 2; do
178+
local ai=${a[$i]:-0} bi=${b[$i]:-0}
179+
if ((ai > bi)); then return 0; fi
180+
if ((ai < bi)); then return 1; fi
181+
done
182+
return 0
183+
}
184+
172185
version_major() {
173186
printf '%s\n' "${1#v}" | cut -d. -f1
174187
}
@@ -186,7 +199,7 @@ ensure_supported_runtime() {
186199
[[ "$node_major" =~ ^[0-9]+$ ]] || fail "Could not determine Node.js version from '${node_version}'. ${RUNTIME_REQUIREMENT_MSG}"
187200
[[ "$npm_major" =~ ^[0-9]+$ ]] || fail "Could not determine npm version from '${npm_version}'. ${RUNTIME_REQUIREMENT_MSG}"
188201

189-
if ((node_major < MIN_NODE_MAJOR || npm_major < MIN_NPM_MAJOR)); then
202+
if ! version_gte "${node_version#v}" "$MIN_NODE_VERSION" || ((npm_major < MIN_NPM_MAJOR)); then
190203
fail "Unsupported runtime detected: Node.js ${node_version:-unknown}, npm ${npm_version:-unknown}. ${RUNTIME_REQUIREMENT_MSG} Upgrade Node.js and rerun the installer."
191204
fi
192205

@@ -196,13 +209,13 @@ ensure_supported_runtime() {
196209
# ── Install Node.js 22 if needed ────────────────────────────────
197210

198211
install_node() {
199-
local current_major=""
212+
local current_version=""
200213
if command -v node >/dev/null 2>&1; then
201-
current_major="$(node -v 2>/dev/null | sed 's/^v//' | cut -d. -f1)"
214+
current_version="$(node -v 2>/dev/null | sed 's/^v//')"
202215
fi
203216

204-
if [ "$current_major" = "22" ]; then
205-
info "Node.js 22 already installed: $(node -v)"
217+
if [ -n "$current_version" ] && version_gte "$current_version" "$MIN_NODE_VERSION"; then
218+
info "Node.js v${current_version} meets minimum requirement (>= v${MIN_NODE_VERSION})"
206219
return 0
207220
fi
208221

‎test/install-preflight.test.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function writeExecutable(target, contents) {
2020
// Helpers shared across suites
2121
// ---------------------------------------------------------------------------
2222

23-
/** Fake node that reports v22.14.0. */
23+
/** Fake node that reports v22.16.0. */
2424
function writeNodeStub(fakeBin) {
2525
writeExecutable(
2626
path.join(fakeBin, "node"),
2727
`#!/usr/bin/env bash
28-
if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then echo "v22.14.0"; exit 0; fi
28+
if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then echo "v22.16.0"; exit 0; fi
2929
if [ "$1" = "-e" ]; then
3030
if [[ "$2" == *"dependencies.openclaw"* ]]; then
3131
echo "2026.3.11"
@@ -100,7 +100,7 @@ exit 98
100100
const output = `${result.stdout}${result.stderr}`;
101101
expect(result.status).not.toBe(0);
102102
expect(output).toMatch(/Unsupported runtime detected/);
103-
expect(output).toMatch(/Node\.js >=20 and npm >=10/);
103+
expect(output).toMatch(/Node\.js >=22\.16\.0 and npm >=10/);
104104
expect(output).toMatch(/v18\.19\.1/);
105105
expect(output).toMatch(/9\.8\.1/);
106106
});
@@ -117,7 +117,7 @@ exit 98
117117
path.join(fakeBin, "node"),
118118
`#!/usr/bin/env bash
119119
if [ "$1" = "--version" ]; then
120-
echo "v22.14.0"
120+
echo "v22.16.0"
121121
exit 0
122122
fi
123123
if [ "$1" = "-e" ]; then
@@ -212,7 +212,7 @@ exit 98
212212
path.join(fakeBin, "node"),
213213
`#!/usr/bin/env bash
214214
if [ "$1" = "--version" ]; then
215-
echo "v22.14.0"
215+
echo "v22.16.0"
216216
exit 0
217217
fi
218218
if [ "$1" = "-e" ]; then
@@ -295,7 +295,7 @@ exit 98
295295
path.join(fakeBin, "node"),
296296
`#!/usr/bin/env bash
297297
if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
298-
echo "v22.14.0"
298+
echo "v22.16.0"
299299
exit 0
300300
fi
301301
exit 99
@@ -375,7 +375,7 @@ echo "Darwin"
375375
path.join(fakeBin, "node"),
376376
`#!/usr/bin/env bash
377377
if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
378-
echo "v22.14.0"
378+
echo "v22.16.0"
379379
exit 0
380380
fi
381381
if [ "$1" = "-e" ]; then
@@ -641,7 +641,7 @@ fi`,
641641
path.join(fakeBin, "node"),
642642
`#!/usr/bin/env bash
643643
if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
644-
echo "v22.14.0"
644+
echo "v22.16.0"
645645
exit 0
646646
fi
647647
if [ "$1" = "-e" ]; then

0 commit comments

Comments
 (0)