Skip to content

Commit ab5048a

Browse files
authored
fix: pre-extract openclaw with system tar to unblock installs (#503) (#505)
The openclaw npm tarball is missing directory entries for extensions/, skills/, and dist/plugin-sdk/config/. npm's tar extractor hard-fails on these, and the @whiskeysockets/baileys postinstall then crashes with `spawn sh ENOENT`, killing the entire install. Fix: pre-extract openclaw into node_modules using system tar (which handles missing directory entries) BEFORE npm install, so npm sees the dependency is already satisfied and skips the broken download. Both install scripts now clone the repo, pre-extract openclaw, then run `npm install --ignore-scripts` + build + `npm link` instead of the previous `npm install -g git+url` which we can't hook into. The pre-extraction is non-fatal — if it fails, the install continues and will succeed once the upstream tarball is fixed. Fixes #503
1 parent 3aaef13 commit ab5048a

3 files changed

Lines changed: 227 additions & 15 deletions

File tree

‎install.sh‎

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,68 @@ install_or_upgrade_ollama() {
219219
# ---------------------------------------------------------------------------
220220
# 3. NemoClaw
221221
# ---------------------------------------------------------------------------
222+
# Work around openclaw tarball missing directory entries (GH-503).
223+
# npm's tar extractor hard-fails because the tarball is missing directory
224+
# entries for extensions/, skills/, and dist/plugin-sdk/config/. System tar
225+
# handles this fine. We pre-extract openclaw into node_modules BEFORE npm
226+
# install so npm sees the dependency is already satisfied and skips it.
227+
pre_extract_openclaw() {
228+
local install_dir="$1"
229+
local openclaw_version
230+
openclaw_version=$(node -e "console.log(require('${install_dir}/package.json').dependencies.openclaw)" 2>/dev/null || echo "")
231+
232+
if [[ -z "$openclaw_version" ]]; then
233+
warn "Could not determine openclaw version — skipping pre-extraction"
234+
return 1
235+
fi
236+
237+
info "Pre-extracting openclaw@${openclaw_version} with system tar (GH-503 workaround)…"
238+
local tmpdir
239+
tmpdir="$(mktemp -d)"
240+
if npm pack "openclaw@${openclaw_version}" --pack-destination "$tmpdir" > /dev/null 2>&1; then
241+
local tgz
242+
tgz="$(find "$tmpdir" -maxdepth 1 -name 'openclaw-*.tgz' -print -quit)"
243+
if [[ -n "$tgz" && -f "$tgz" ]]; then
244+
if mkdir -p "${install_dir}/node_modules/openclaw" \
245+
&& tar xzf "$tgz" -C "${install_dir}/node_modules/openclaw" --strip-components=1
246+
then
247+
info "openclaw pre-extracted successfully"
248+
else
249+
warn "Failed to extract openclaw tarball"
250+
rm -rf "$tmpdir"
251+
return 1
252+
fi
253+
else
254+
warn "npm pack succeeded but tarball not found"
255+
rm -rf "$tmpdir"
256+
return 1
257+
fi
258+
else
259+
warn "Failed to download openclaw tarball"
260+
rm -rf "$tmpdir"
261+
return 1
262+
fi
263+
rm -rf "$tmpdir"
264+
}
265+
222266
install_nemoclaw() {
223267
if [[ -f "./package.json" ]] && grep -q '"name": "nemoclaw"' ./package.json 2>/dev/null; then
224268
info "NemoClaw package.json found in current directory — installing from source…"
225-
npm install && npm link
269+
pre_extract_openclaw "$(pwd)" || warn "Pre-extraction failed — npm install may fail if openclaw tarball is broken"
270+
npm install --ignore-scripts
271+
(cd nemoclaw && npm install --ignore-scripts && npm run build)
272+
npm link
226273
else
227274
info "Installing NemoClaw from GitHub…"
228-
# Revert once https://github.com/NVIDIA/NemoClaw/issues/71 is complete and the package is published
229-
npm install -g git+https://github.com/NVIDIA/NemoClaw.git
275+
# Clone first so we can pre-extract openclaw before npm install (GH-503).
276+
# npm install -g git+https://... does this internally but we can't hook
277+
# into its extraction pipeline, so we do it ourselves.
278+
local nemoclaw_src="${HOME}/.nemoclaw/source"
279+
rm -rf "$nemoclaw_src"
280+
mkdir -p "$(dirname "$nemoclaw_src")"
281+
git clone --depth 1 https://github.com/NVIDIA/NemoClaw.git "$nemoclaw_src"
282+
pre_extract_openclaw "$nemoclaw_src" || warn "Pre-extraction failed — npm install may fail if openclaw tarball is broken"
283+
(cd "$nemoclaw_src" && npm install --ignore-scripts && cd nemoclaw && npm install --ignore-scripts && npm run build && cd .. && npm link)
230284
fi
231285

232286
refresh_path

‎scripts/install.sh‎

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,68 @@ install_openshell() {
359359

360360
install_openshell
361361

362+
# ── Pre-extract openclaw workaround (GH-503) ────────────────────
363+
# The openclaw npm tarball is missing directory entries for extensions/,
364+
# skills/, and dist/plugin-sdk/config/. npm's tar extractor hard-fails on
365+
# these but system tar handles them fine. We pre-extract openclaw into
366+
# node_modules BEFORE npm install so npm sees the dep is already satisfied.
367+
pre_extract_openclaw() {
368+
local install_dir="$1"
369+
local openclaw_version
370+
openclaw_version=$(node -e "console.log(require('${install_dir}/package.json').dependencies.openclaw)" 2>/dev/null) || openclaw_version=""
371+
372+
if [ -z "$openclaw_version" ]; then
373+
warn "Could not determine openclaw version — skipping pre-extraction"
374+
return 1
375+
fi
376+
377+
info "Pre-extracting openclaw@${openclaw_version} with system tar (GH-503 workaround)…"
378+
local tmpdir
379+
tmpdir="$(mktemp -d)"
380+
if npm pack "openclaw@${openclaw_version}" --pack-destination "$tmpdir" > /dev/null 2>&1; then
381+
local tgz
382+
tgz="$(find "$tmpdir" -maxdepth 1 -name 'openclaw-*.tgz' -print -quit)"
383+
if [ -n "$tgz" ] && [ -f "$tgz" ]; then
384+
if mkdir -p "${install_dir}/node_modules/openclaw" \
385+
&& tar xzf "$tgz" -C "${install_dir}/node_modules/openclaw" --strip-components=1
386+
then
387+
info "openclaw pre-extracted successfully"
388+
else
389+
warn "Failed to extract openclaw tarball"
390+
rm -rf "$tmpdir"
391+
return 1
392+
fi
393+
else
394+
warn "npm pack succeeded but tarball not found"
395+
rm -rf "$tmpdir"
396+
return 1
397+
fi
398+
else
399+
warn "Failed to download openclaw tarball"
400+
rm -rf "$tmpdir"
401+
return 1
402+
fi
403+
rm -rf "$tmpdir"
404+
}
405+
362406
# ── Install NemoClaw CLI ─────────────────────────────────────────
363407

364408
info "Installing nemoclaw CLI..."
365-
if [ "$NODE_MGR" = "nodesource" ]; then
366-
sudo npm install -g git+https://github.com/NVIDIA/NemoClaw.git
367-
else
368-
npm install -g git+https://github.com/NVIDIA/NemoClaw.git
409+
# Clone first so we can pre-extract openclaw before npm install (GH-503).
410+
# npm install -g git+https://... does this internally but we can't hook
411+
# into its extraction pipeline, so we do it ourselves.
412+
NEMOCLAW_SRC="${HOME}/.nemoclaw/source"
413+
rm -rf "$NEMOCLAW_SRC"
414+
mkdir -p "$(dirname "$NEMOCLAW_SRC")"
415+
git clone --depth 1 https://github.com/NVIDIA/NemoClaw.git "$NEMOCLAW_SRC"
416+
pre_extract_openclaw "$NEMOCLAW_SRC" || warn "Pre-extraction failed — npm install may fail if openclaw tarball is broken"
417+
# Use sudo for npm link when the global prefix requires it (e.g., nodesource),
418+
# but skip sudo if already root (e.g., Docker containers).
419+
SUDO=""
420+
if [ "$NODE_MGR" = "nodesource" ] && [ "$(id -u)" -ne 0 ]; then
421+
SUDO="sudo"
369422
fi
423+
(cd "$NEMOCLAW_SRC" && npm install --ignore-scripts && cd nemoclaw && npm install --ignore-scripts && npm run build && cd .. && $SUDO npm link)
370424

371425
if [ "$NEED_RESHIM" = true ]; then
372426
info "Reshimming asdf..."

‎test/install-preflight.test.js‎

Lines changed: 112 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ exit 98
6969
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-install-fallback-"));
7070
const fakeBin = path.join(tmp, "bin");
7171
const prefix = path.join(tmp, "prefix");
72-
const npmLog = path.join(tmp, "npm.log");
72+
const gitLog = path.join(tmp, "git.log");
7373
fs.mkdirSync(fakeBin);
7474
fs.mkdirSync(path.join(prefix, "bin"), { recursive: true });
7575

@@ -80,16 +80,33 @@ if [ "$1" = "--version" ]; then
8080
echo "v22.14.0"
8181
exit 0
8282
fi
83+
if [ "$1" = "-e" ]; then
84+
exit 1
85+
fi
8386
echo "unexpected node invocation: $*" >&2
8487
exit 99
8588
`,
8689
);
8790

91+
writeExecutable(
92+
path.join(fakeBin, "git"),
93+
`#!/usr/bin/env bash
94+
printf '%s\\n' "$*" >> "$GIT_LOG_PATH"
95+
if [ "$1" = "clone" ]; then
96+
target="\${@: -1}"
97+
mkdir -p "$target/nemoclaw"
98+
echo '{"name":"nemoclaw","version":"0.1.0","dependencies":{"openclaw":"2026.3.11"}}' > "$target/package.json"
99+
echo '{"name":"nemoclaw-plugin","version":"0.1.0"}' > "$target/nemoclaw/package.json"
100+
exit 0
101+
fi
102+
exit 0
103+
`,
104+
);
105+
88106
writeExecutable(
89107
path.join(fakeBin, "npm"),
90108
`#!/usr/bin/env bash
91109
set -euo pipefail
92-
printf '%s\\n' "$*" >> "$NPM_LOG_PATH"
93110
if [ "$1" = "--version" ]; then
94111
echo "10.9.2"
95112
exit 0
@@ -98,7 +115,16 @@ if [ "$1" = "config" ] && [ "$2" = "get" ] && [ "$3" = "prefix" ]; then
98115
echo "$NPM_PREFIX"
99116
exit 0
100117
fi
101-
if [ "$1" = "install" ] && [ "$2" = "-g" ] && [ "$3" = "${GITHUB_INSTALL_URL}" ]; then
118+
if [ "$1" = "pack" ]; then
119+
exit 1
120+
fi
121+
if [ "$1" = "install" ] && [[ "$*" == *"--ignore-scripts"* ]]; then
122+
exit 0
123+
fi
124+
if [ "$1" = "run" ]; then
125+
exit 0
126+
fi
127+
if [ "$1" = "link" ]; then
102128
cat > "$NPM_PREFIX/bin/nemoclaw" <<'EOS'
103129
#!/usr/bin/env bash
104130
if [ "$1" = "onboard" ]; then
@@ -127,12 +153,12 @@ exit 98
127153
PATH: `${fakeBin}:${TEST_SYSTEM_PATH}`,
128154
NEMOCLAW_NON_INTERACTIVE: "1",
129155
NPM_PREFIX: prefix,
130-
NPM_LOG_PATH: npmLog,
156+
GIT_LOG_PATH: gitLog,
131157
},
132158
});
133159

134160
assert.equal(result.status, 0);
135-
assert.match(fs.readFileSync(npmLog, "utf-8"), new RegExp(`install -g ${GITHUB_INSTALL_URL.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`));
161+
assert.match(fs.readFileSync(gitLog, "utf-8"), /clone.*NemoClaw\.git/);
136162
});
137163

138164
it("prints the HTTPS GitHub remediation when the binary is missing", () => {
@@ -149,11 +175,28 @@ if [ "$1" = "--version" ]; then
149175
echo "v22.14.0"
150176
exit 0
151177
fi
178+
if [ "$1" = "-e" ]; then
179+
exit 1
180+
fi
152181
echo "unexpected node invocation: $*" >&2
153182
exit 99
154183
`,
155184
);
156185

186+
writeExecutable(
187+
path.join(fakeBin, "git"),
188+
`#!/usr/bin/env bash
189+
if [ "$1" = "clone" ]; then
190+
target="\${@: -1}"
191+
mkdir -p "$target/nemoclaw"
192+
echo '{"name":"nemoclaw","version":"0.1.0","dependencies":{"openclaw":"2026.3.11"}}' > "$target/package.json"
193+
echo '{"name":"nemoclaw-plugin","version":"0.1.0"}' > "$target/nemoclaw/package.json"
194+
exit 0
195+
fi
196+
exit 0
197+
`,
198+
);
199+
157200
writeExecutable(
158201
path.join(fakeBin, "npm"),
159202
`#!/usr/bin/env bash
@@ -166,7 +209,16 @@ if [ "$1" = "config" ] && [ "$2" = "get" ] && [ "$3" = "prefix" ]; then
166209
echo "$NPM_PREFIX"
167210
exit 0
168211
fi
169-
if [ "$1" = "install" ] && [ "$2" = "-g" ] && [ "$3" = "${GITHUB_INSTALL_URL}" ]; then
212+
if [ "$1" = "pack" ]; then
213+
exit 1
214+
fi
215+
if [ "$1" = "install" ] && [[ "$*" == *"--ignore-scripts"* ]]; then
216+
exit 0
217+
fi
218+
if [ "$1" = "run" ]; then
219+
exit 0
220+
fi
221+
if [ "$1" = "link" ]; then
170222
exit 0
171223
fi
172224
echo "unexpected npm invocation: $*" >&2
@@ -286,10 +338,27 @@ if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
286338
echo "v22.14.0"
287339
exit 0
288340
fi
341+
if [ "$1" = "-e" ]; then
342+
exit 1
343+
fi
289344
exit 99
290345
`,
291346
);
292347

348+
writeExecutable(
349+
path.join(fakeBin, "git"),
350+
`#!/usr/bin/env bash
351+
if [ "$1" = "clone" ]; then
352+
target="\${@: -1}"
353+
mkdir -p "$target/nemoclaw"
354+
echo '{"name":"nemoclaw","version":"0.1.0","dependencies":{"openclaw":"2026.3.11"}}' > "$target/package.json"
355+
echo '{"name":"nemoclaw-plugin","version":"0.1.0"}' > "$target/nemoclaw/package.json"
356+
exit 0
357+
fi
358+
exit 0
359+
`,
360+
);
361+
293362
writeExecutable(
294363
path.join(fakeBin, "npm"),
295364
`#!/usr/bin/env bash
@@ -302,7 +371,16 @@ if [ "$1" = "config" ] && [ "$2" = "get" ] && [ "$3" = "prefix" ]; then
302371
echo "$NPM_PREFIX"
303372
exit 0
304373
fi
305-
if [ "$1" = "install" ] && [ "$2" = "-g" ]; then
374+
if [ "$1" = "pack" ]; then
375+
exit 1
376+
fi
377+
if [ "$1" = "install" ] && [[ "$*" == *"--ignore-scripts"* ]]; then
378+
exit 0
379+
fi
380+
if [ "$1" = "run" ]; then
381+
exit 0
382+
fi
383+
if [ "$1" = "link" ]; then
306384
cat > "$NPM_PREFIX/bin/nemoclaw" <<'EOS'
307385
#!/usr/bin/env bash
308386
if [ "$1" = "--version" ]; then
@@ -375,10 +453,27 @@ if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
375453
echo "v22.14.0"
376454
exit 0
377455
fi
456+
if [ "$1" = "-e" ]; then
457+
exit 1
458+
fi
378459
exit 99
379460
`,
380461
);
381462

463+
writeExecutable(
464+
path.join(fakeBin, "git"),
465+
`#!/usr/bin/env bash
466+
if [ "$1" = "clone" ]; then
467+
target="\${@: -1}"
468+
mkdir -p "$target/nemoclaw"
469+
echo '{"name":"nemoclaw","version":"0.1.0","dependencies":{"openclaw":"2026.3.11"}}' > "$target/package.json"
470+
echo '{"name":"nemoclaw-plugin","version":"0.1.0"}' > "$target/nemoclaw/package.json"
471+
exit 0
472+
fi
473+
exit 0
474+
`,
475+
);
476+
382477
writeExecutable(
383478
path.join(fakeBin, "npm"),
384479
`#!/usr/bin/env bash
@@ -391,7 +486,16 @@ if [ "$1" = "config" ] && [ "$2" = "get" ] && [ "$3" = "prefix" ]; then
391486
echo "$NPM_PREFIX"
392487
exit 0
393488
fi
394-
if [ "$1" = "install" ] && [ "$2" = "-g" ] && [ "$3" = "${GITHUB_INSTALL_URL}" ]; then
489+
if [ "$1" = "pack" ]; then
490+
exit 1
491+
fi
492+
if [ "$1" = "install" ] && [[ "$*" == *"--ignore-scripts"* ]]; then
493+
exit 0
494+
fi
495+
if [ "$1" = "run" ]; then
496+
exit 0
497+
fi
498+
if [ "$1" = "link" ]; then
395499
cat > "$NPM_PREFIX/bin/nemoclaw" <<'EOS'
396500
#!/usr/bin/env bash
397501
if [ "$1" = "onboard" ]; then

0 commit comments

Comments
 (0)