Skip to content

fix: installer removes temporary files after failed commands#104049

Merged
steipete merged 2 commits into
mainfrom
codex/fix-install-sh-temp-cleanup
Jul 11, 2026
Merged

fix: installer removes temporary files after failed commands#104049
steipete merged 2 commits into
mainfrom
codex/fix-install-sh-temp-cleanup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #103725

What Problem This Solves

Fixes an issue where failed primary installer operations could leave downloaded scripts and diagnostic logs in /tmp because their cleanup registrations were lost before the installer exited.

Why This Change Was Made

mktempfile now assigns its result into a caller variable, so the parent shell retains every path in its cleanup list. All seven callers use that interface; the existing Bash 3.2-safe cleanup loop remains unchanged.

This is an AI-assisted maintainer follow-up to the CLI installer cleanup in #103725.

User Impact

Failed and successful install.sh operations now remove installer-owned temporary files while preserving the wrapped command's exit status.

Evidence

  • Blacksmith Testbox tbx_01kx7czzpbmz1019khv7ss8tza (Linux): corepack pnpm test test/scripts/install-sh.test.ts test/scripts/install-cli.test.ts — 91 tests passed.
  • Source-blind behavior validation: failure exits 42 and 43 preserved; randomized temp paths removed; success exit 0 also cleaned up.
  • /bin/bash -n scripts/install.sh
  • pnpm exec oxfmt --check test/scripts/install-sh.test.ts
  • git diff --check
  • Fresh Codex autoreview: clean, no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 10, 2026, 9:52 PM ET / July 11, 2026, 01:52 UTC.

Summary
The PR changes scripts/install.sh temporary-file creation to assign paths into caller variables so EXIT cleanup registrations persist, updates all seven callers, and adds a failed remote-script cleanup regression test.

PR surface: Tests +32, Other +2. Total +34 across 2 files.

Reproducibility: yes. On current main, tmp="$(mktempfile)" executes the helper in a subshell, so the parent TMPFILES array remains unaware of the generated path and cannot remove it on exit.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: test/scripts/install-sh.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P1] No automated repair is needed; the remaining work is normal protected-label maintainer review and exact-head check completion.

Security
Cleared: The diff changes local Bash variable assignment and a regression test only, adding no dependency, workflow, permission, secret, package-resolution, lifecycle-hook, or download-source surface.

Review details

Best possible solution:

Merge the focused caller-scope registration change once exact-head checks finish, retaining one EXIT-owned cleanup list and the wrapped command's original exit status.

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

Yes. On current main, tmp="$(mktempfile)" executes the helper in a subshell, so the parent TMPFILES array remains unaware of the generated path and cannot remove it on exit.

Is this the best way to solve the issue?

Yes. Assigning into a named caller variable fixes the root Bash scope issue, converts every affected caller, preserves the existing cleanup lifecycle, and follows the merged sibling installer pattern instead of adding a competing cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 67e1d4391153.

Label changes

Label changes:

  • add P2: The PR fixes bounded temporary-file leakage during failed installer operations without affecting core runtime availability or persisted user data.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is marked as maintainer work; its body nevertheless records Blacksmith Testbox and source-blind terminal validation of exit-code preservation and temporary-path removal.

Label justifications:

  • P2: The PR fixes bounded temporary-file leakage during failed installer operations without affecting core runtime availability or persisted user data.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is marked as maintainer work; its body nevertheless records Blacksmith Testbox and source-blind terminal validation of exit-code preservation and temporary-path removal.
Evidence reviewed

PR surface:

Tests +32, Other +2. Total +34 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 33 1 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 12 10 +2
Total 2 45 11 +34

What I checked:

  • Current-main bug: mktempfile appends to TMPFILES, while each affected caller captures its output with command substitution; the helper therefore mutates a subshell copy rather than the parent array used by the EXIT trap. (scripts/install.sh:51, 67e1d4391153)
  • Complete caller migration: The branch changes every mktempfile caller—remote scripts, spinner output, quiet-step logs, npm diagnostics, and three NodeSource branches—to use caller-scope assignment. (scripts/install.sh:51, 25af7f54deff)
  • Regression coverage: The added test forces a downloaded script to exit 42, verifies the exit status is preserved, verifies the generated file is removed by the EXIT trap, and guards against reintroducing command-substitution calls. (test/scripts/install-sh.test.ts:58, 25af7f54deff)
  • Sibling implementation precedent: Merged PR fix(install-cli): track mktemp paths and clean up on EXIT #103725 registers temporary paths directly in the parent shell for install-cli.sh, documenting the same command-substitution subshell invariant. (scripts/install-cli.sh:32, 95b205eac28d)
  • No touched-file base drift: Current main has no changes to either touched file after the PR base, so the reviewed patch still targets the same source and test context. (scripts/install.sh:51, 67e1d4391153)
  • Protected review routing: The live PR carries the maintainer label, which prevents conservative ClawSweeper auto-close even though the patch review is clean. (25af7f54deff)

Likely related people:

  • steipete: Current-main blame and history tie the primary installer cleanup helper and affected callers to Peter Steinberger's imported installer work; he also authored this follow-up. (role: introduced current behavior; confidence: high; commits: 0120cacf9e4e; files: scripts/install.sh, test/scripts/install-sh.test.ts)
  • SebTardif: Authored the merged sibling CLI-installer cleanup that established direct parent-shell temporary-path registration and failure-path coverage. (role: introduced sibling behavior; confidence: high; commits: 95b205eac28d; files: scripts/install-cli.sh, test/scripts/install-cli.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 25af7f54deff5ee6b8ccbeb78df048935e734b06:

  • Blacksmith Testbox tbx_01kx7czzpbmz1019khv7ss8tza: corepack pnpm test test/scripts/install-sh.test.ts test/scripts/install-cli.test.ts — 91/91 passed on Linux.
  • Source-blind behavior validation: independent failure exits 42 and 43 propagated while randomized downloaded-script paths were removed; success exit 0 also cleaned up.
  • /bin/bash -n scripts/install.sh
  • pnpm exec oxfmt --check test/scripts/install-sh.test.ts
  • git diff --check
  • Fresh Codex autoreview: clean, no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/29135221163 — 55/55 jobs completed successfully.
  • Repo-native review artifacts: READY FOR /prepare-pr, zero findings; OPENCLAW_TESTBOX=1 scripts/pr prepare-run 104049 passed.

Known proof gaps: none.

@steipete
steipete merged commit f50293c into main Jul 11, 2026
110 of 114 checks passed
@steipete
steipete deleted the codex/fix-install-sh-temp-cleanup branch July 11, 2026 01:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…w#104049)

* fix(installer): retain temp cleanup registrations

* chore: keep installer release notes release-owned
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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant