Skip to content

fix(install): repair set-npm-prefix rc line and surface silent finalization failures - #133869

Merged
steipete merged 1 commit into
mainfrom
steipete/installer-audit-fixes
Aug 31, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/installer-audit-fixes

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

A full audit of the three hosted installers (run from openclaw.ai against the synced copies, verified against this repo's scripts/ sources) found several verified defects. This PR fixes the three highest-confidence shell ones; the remaining findings are listed below for follow-up.

Fixed here

  1. install-cli.sh --set-npm-prefix corrupted shell rc files (P1). The PATH line was over-escaped: \\\" collapsed to a literal \" and \\$PATH expanded at install time, so .bashrc/.zshrc received a line wrapped in literal backslash-quotes containing a frozen snapshot of the install-time PATH. The npm-global bin dir was never actually resolvable from it, and the user's PATH was frozen to install-time values. install.sh already used the correct form; this backports it.
  2. install.sh could exit 1 with zero output (P1). The finalization helpers (retire_npm_owner_after_git_install, retire_git_wrapper_after_npm_install) had silent fatal paths; each now prints an actionable error. prepare_git_wrapper_backup_for_npm no longer hard-fails when npm is missing (Arch installs node without npm): there is nothing to back up, and the npm install step already reports missing npm with remediation — previously that case died silently before any message.
  3. install-cli.sh --compatible-with with an unresolvable --version died silently. The failed npm view killed the script through set -e before the intended fail (and its JSON error event) could run; the resolution failure now reaches the explicit error path.

Verification

  • pnpm vitest run test/scripts/install-cli.test.ts test/scripts/install-sh.test.ts — 270/270 pass with these changes.
  • bash -n and shellcheck -S warning clean on both scripts.
  • Reproduced the rc-line corruption before/after: old form writes export PATH=\"/home/u/.npm-global/bin:\<frozen 1KB PATH snapshot>\", new form writes export PATH="/home/u/.npm-global/bin:$PATH".
  • Downstream openclaw.ai Docker lanes (root, non-root, git, cli-git, e2e, 4-distro matrix) all pass against the current installers.

Proposed changelog entry (not included: add on merge)

Installer diagnostics: stop install-cli.sh --set-npm-prefix from writing an over-escaped PATH line with a frozen install-time PATH snapshot into shell rc files, surface the previously silent npm retirement/backup failures in install.sh with actionable errors (including the Arch node-without-npm case), and report an explicit error when --compatible-with cannot resolve the requested version instead of exiting silently.

Audit findings NOT fixed here (follow-ups, roughly by priority)

  • install.ps1 (P1): on Windows PowerShell 5.1, $ErrorActionPreference = "Stop" + stderr redirection (2>&1 / 2>$null) can abort mid-install on the first npm stderr warning; several call sites are unguarded (e.g. npm config get min-release-age), and the npm-failure diagnostics path itself can be killed by npm's own npm error output.
  • install.ps1 (P1): when winget/choco/scoop is detected but fails (non-admin, lagging package), Install-Node aborts instead of falling through to the elevation-free portable Node path; the winget failure message advises a rerun that deterministically fails again.
  • install.sh / install.ps1 (P2): both force --min-release-age=0 (install.sh's user-configured branch assigns the same value, making it dead code), silently defeating a user's supply-chain cooldown; decide whether that override is intentional and log it either way.
  • install.sh (P2): gum UI never activates under curl | bash (stdin-pipe check runs before the controlling-TTY check), so the rich UI only appears for file-based runs; shell GIT_DIR variable can collide with an exported git GIT_DIR env var; exec openclaw onboard skips the temp-file cleanup trap; --dry-run downloads gum before the dry-run gate; --version latest for the git method silently degrades to moving main when the registry is unreachable (and resolve_git_openclaw_ref uses bare npm from PATH instead of the managed $(npm_bin) that install-cli.sh uses).
  • install-cli.sh (P2): --json NDJSON stdout gets polluted by npm/pnpm child output; several set -e death paths emit no JSON error event; sudo/git prompts can still block a TTY-attached non-interactive run (sudo -n / GIT_TERMINAL_PROMPT=0 are unset); managed-Node upgrade removes the old runtime before the new one is extracted; non-Alpine musl distros get the glibc tarball with a misleading remediation.
  • install.ps1 (P2): no SecurityProtocol TLS floor for PS 5.1; no checksums for portable Node/MinGit; missing -UseBasicParsing on the MinGit download; user PATH rewrite flattens REG_EXPAND_SZ; non-ASCII profile paths break the git-method .cmd wrapper (OEM codepage); Ensure-OpenClawOnPath failure exits 0.

…zation failures

- install-cli.sh --set-npm-prefix wrote an over-escaped PATH line: the
  backslash-escaping expanded PATH at install time, appending a literal
  \"-quoted, frozen PATH snapshot to .bashrc/.zshrc that never resolves
  the npm-global bin dir. Use the same correct form as install.sh.
- install.sh finalization helpers (retire_npm_owner_after_git_install,
  retire_git_wrapper_after_npm_install) could abort the install with
  exit 1 and no output; each fatal path now prints an actionable error.
- prepare_git_wrapper_backup_for_npm no longer hard-fails when npm is
  missing (Arch splits node/npm): there is nothing to back up, and the
  npm install step already reports the missing npm with remediation.
- install-cli.sh --compatible-with with an unresolvable --version died
  silently through set -e before its error message; the failed npm view
  now reaches the explicit fail path (and the JSON error event).
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS maintainer Maintainer-authored PR labels Aug 31, 2026
@steipete
steipete enabled auto-merge (squash) August 31, 2026 06:31
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 31, 2026, 2:31 AM ET / 06:31 UTC.

ClawSweeper review

What this changes

The PR fixes the CLI installer’s shell startup PATH line and makes npm-version resolution and install finalization failures visible to operators.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The branch directly repairs current-main installer defects, but it changes only production scripts and lacks focused regression coverage for the repaired shell output and formerly silent failures.

Priority: P2
Reviewed head: d60a2f28016c7ea811f13b63c0c125e7230318d7

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair is source-supported and narrowly scoped, but the modified behavior has no focused regression coverage in the branch.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; its captured body reports terminal and Docker validation but no artifact was independently inspected.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies this as a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; its captured body reports terminal and Docker validation but no artifact was independently inspected.
Evidence reviewed 6 items Introduced shell configuration repair: The introduced hunk changes the rc-file text to preserve a literal $PATH for the next shell, rather than writing escaped quotes and an install-time expansion.
Explicit compatibility-resolution failure: The compatibility path now converts a failed npm version lookup into the existing explicit fail path before package installation.
Finalization caller and owner: The main flow calls the npm-to-Git retirement after a Git install and the Git-wrapper retirement after verified npm installation; the changed helpers now report their failure causes before returning nonzero.
Findings 1 actionable finding [P2] Add regression coverage for the repaired installer boundaries
Security None None.

How this fits together

The shell installers provision OpenClaw through npm or a Git checkout, update login-shell configuration, and retire replaced launchers. Their finalization paths determine whether users receive a usable command or an actionable failure.

flowchart LR
  A[Installer options] --> B[CLI installer]
  B --> C[Shell startup file]
  B --> D[Version compatibility check]
  E[Git or npm installation] --> F[Install finalization]
  F --> G[Launcher transition]
  C --> H[Usable OpenClaw command]
  D --> H
  G --> H
Loading

Before merge

  • Add regression coverage for the repaired installer boundaries (P2) - This production-only diff changes the exact rc-file serialization and three previously silent failure paths, but the branch adds no tests. Add shell-boundary regressions for a literal $PATH after sourcing the written rc file, failed npm view compatibility resolution, and finalization errors; otherwise these repairs can regress while the current suite still passes.
  • Resolve merge risk (P1) - The latest ClawSweeper comment body was not supplied, and the live GitHub read failed in this environment; verify any current Rank-up moves before merge.
  • Complete next step (P2) - This maintainer-labelled PR has a concrete contributor-side test gap and should remain in normal human review rather than enter an automated repair lane.

Findings

  • [P2] Add regression coverage for the repaired installer boundaries — scripts/install-cli.sh:1228
Agent review details

Security

None.

PR surface

Other +20. Total +20 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 29 9 +20
Total 2 29 9 +20

Review metrics

Metric Value Why it matters
Production versus test delta production +20/-9 (net +20); tests +0/-0 The added guards and diagnostics provide observable failure outcomes, but the repaired behavior has no corresponding regression-test delta.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Add focused before/after shell-boundary regressions for the rc-file line and each newly explicit failure path, then retain this producer-side repair.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Add focused before/after shell-boundary regressions for the rc-file line and each newly explicit failure path, then retain this producer-side repair.

Do we have a high-confidence way to reproduce the issue?

No independent high-confidence run was executed in this read-only review; the old and new shell expansions make the rc-file defect source-reproducible, and the captured PR body reports a before/after run.

Is this the best way to solve the issue?

Yes, conditionally. The patch repairs the producer of the malformed shell line and the set-e exits rather than compensating downstream, but needs direct regression coverage for those boundaries.

Full review comments:

  • [P2] Add regression coverage for the repaired installer boundaries — scripts/install-cli.sh:1228
    This production-only diff changes the exact rc-file serialization and three previously silent failure paths, but the branch adds no tests. Add shell-boundary regressions for a literal $PATH after sourcing the written rc file, failed npm view compatibility resolution, and finalization errors; otherwise these repairs can regress while the current suite still passes.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 70338624f636.

Labels

Label changes:

  • add P2: This is a bounded installer reliability repair that can affect shell startup configuration and diagnostic quality for affected installs.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied repository state identifies this as a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; its captured body reports terminal and Docker validation but no artifact was independently inspected.

Label justifications:

  • P2: This is a bounded installer reliability repair that can affect shell startup configuration and diagnostic quality for affected installs.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied repository state identifies this as a member-authored, maintainer-labelled PR, so the external-contributor proof gate does not apply; its captured body reports terminal and Docker validation but no artifact was independently inspected.

Evidence

What I checked:

  • Introduced shell configuration repair: The introduced hunk changes the rc-file text to preserve a literal $PATH for the next shell, rather than writing escaped quotes and an install-time expansion. (scripts/install-cli.sh:1228, d60a2f28016c)
  • Explicit compatibility-resolution failure: The compatibility path now converts a failed npm version lookup into the existing explicit fail path before package installation. (scripts/install-cli.sh:1405, d60a2f28016c)
  • Finalization caller and owner: The main flow calls the npm-to-Git retirement after a Git install and the Git-wrapper retirement after verified npm installation; the changed helpers now report their failure causes before returning nonzero. (scripts/install.sh:3815, d60a2f28016c)
  • Current-main comparison: The fetched current-main revision remains identical to the PR base for both installer files and retains the over-escaped rc line and silent return paths, so this work is not already implemented on main. (scripts/install-cli.sh:1228, 70338624f636)
  • Existing test boundary: Existing tests cover incompatible resolved versions and npm-wrapper rollback, but no test invokes the modified CLI prefix writer or failed npm-view path; this branch changes no tests. (test/scripts/install-cli.test.ts:628, d60a2f28016c)
  • Installer history routing: Recent merged installer work by steipete includes the same two scripts and their targeted tests, making that history a useful routing signal; shallow/promisor history prevented a verified original-introduction claim for the old defective lines. (scripts/install-cli.sh:1228, 5a20edf6a1f9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add focused shell-boundary tests for the corrected rc-file text and explicit failure output.
  • Check the latest ClawSweeper review comment and address or explicitly skip its current Rank-up moves before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit a91edbc into main Aug 31, 2026
165 checks passed
@steipete
steipete deleted the steipete/installer-audit-fixes branch August 31, 2026 06:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…zation failures (openclaw#133869)

- install-cli.sh --set-npm-prefix wrote an over-escaped PATH line: the
  backslash-escaping expanded PATH at install time, appending a literal
  \"-quoted, frozen PATH snapshot to .bashrc/.zshrc that never resolves
  the npm-global bin dir. Use the same correct form as install.sh.
- install.sh finalization helpers (retire_npm_owner_after_git_install,
  retire_git_wrapper_after_npm_install) could abort the install with
  exit 1 and no output; each fatal path now prints an actionable error.
- prepare_git_wrapper_backup_for_npm no longer hard-fails when npm is
  missing (Arch splits node/npm): there is nothing to back up, and the
  npm install step already reports the missing npm with remediation.
- install-cli.sh --compatible-with with an unresolvable --version died
  silently through set -e before its error message; the failed npm view
  now reaches the explicit fail path (and the JSON error event).
steipete pushed a commit that referenced this pull request Sep 19, 2026
#134386)

Windows installations can now recover automatically when winget, Chocolatey, or Scoop fails or leaves an unsupported Node.js runtime. Guarded package-manager attempts warn and continue through the remaining methods to the existing elevation-free portable Node installer. Runtime validation still gates OpenClaw installation.

The installer remains the sole owner of runtime provisioning. Updated Windows documentation and regression coverage describe and protect failure fallthrough, successful recovery, and final refusal when no usable runtime can be provisioned.

Validation: all 99 exact-head checks completed without failures, including Windows installer CI and openclaw/ci-gate. The isolated Windows recovery trace exercised real portable download, extraction, PATH recovery, and runtime/SQLite validation after an injected Chocolatey failure. Codex review was scoped-clean; ClawSweeper reported no actionable findings or Rank-up moves.

Related: #133869
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
openclaw#134386)

Windows installations can now recover automatically when winget, Chocolatey, or Scoop fails or leaves an unsupported Node.js runtime. Guarded package-manager attempts warn and continue through the remaining methods to the existing elevation-free portable Node installer. Runtime validation still gates OpenClaw installation.

The installer remains the sole owner of runtime provisioning. Updated Windows documentation and regression coverage describe and protect failure fallthrough, successful recovery, and final refusal when no usable runtime can be provisioned.

Validation: all 99 exact-head checks completed without failures, including Windows installer CI and openclaw/ci-gate. The isolated Windows recovery trace exercised real portable download, extraction, PATH recovery, and runtime/SQLite validation after an injected Chocolatey failure. Codex review was scoped-clean; ClawSweeper reported no actionable findings or Rank-up moves.

Related: openclaw#133869
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant