Skip to content

fix: let a Windows reinstall replace the existing openclaw command - #203588

Merged
steipete merged 1 commit into
mainfrom
codex/m25-install-ps1-wrapper-replace
Nov 22, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/m25-install-ps1-wrapper-replace

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Re-running the Windows installer (install.ps1) on a machine that already has the openclaw command fails at the very end. The build succeeds, then the installer exits with Exception calling "Replace" with "3" argument(s): "The path is not of a legal form." and leaves the previous openclaw.cmd wrapper in place. A reinstall or repair over an existing install therefore reports failure and can leave the command pointing at the old install.

User Impact

Reinstalling or repairing OpenClaw with install.ps1 over an existing install now updates the openclaw command and finishes successfully.

Why This Change Was Made

Publish-TextFileAtomically swaps the wrapper with [System.IO.File]::Replace($temporaryPath, $Path, $null). PowerShell passes $null to a .NET string parameter as an empty string, and File.Replace rejects an empty backup path. Passing [NullString]::Value sends a real null, meaning no backup, which is what the code intended.

Evidence

  • Windows Server 2025, PowerShell 5.1.26100: the exact call with $null fails with "The path is not of a legal form"; with [NullString]::Value it replaces the file.
  • Live: install.ps1 -InstallMethod git over an existing wrapper exited 1 right after a successful build. Seen in the daily update matrix (Windows Git lane re-install).
  • Test: test/scripts/install-ps1.test.ts "replaces an existing command wrapper when reinstalling" fails on base (The value cannot be an empty string. (Parameter 'path') under pwsh) and passes with the fix. The whole file passes (15 passed, 2 Windows-only skipped).

Introduced by #125992.

…mmand wrapper

Windows PowerShell passes $null to a .NET string parameter as an empty string, so File.Replace(temp, wrapper, $null) in Publish-TextFileAtomically rejected the backup path ('The path is not of a legal form') whenever install.ps1 ran over an existing ~\.local\bin\openclaw.cmd. The build finished but install.ps1 exited 1 and left the previous wrapper in place. Pass [NullString]::Value instead.
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T18:12:51.045436Z f461152 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Nov 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR passes a real null backup path when atomically replacing an existing Windows command wrapper.

Example: Run install.ps1 -InstallMethod git with an existing .local\bin\openclaw.cmd.

  • Before: The build succeeds, but File.Replace rejects the empty backup path and leaves the previous wrapper.
  • After: File.Replace accepts the null backup path and publishes the replacement wrapper.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is narrow and appears correct, with a useful regression test, but the supplied evidence does not satisfy the required installer behavior proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Windows Git reinstalls fail after building and leave the previous command wrapper in place.
Reason: Restoring the existing reinstall contract has clear user value, and the maintainer-authored direction requires no additional product decision.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR makes a focused correction to a reproducible Windows reinstall failure that remains on current main; no introduced code defect was found.

Priority: P1
Reviewed head: f461152bbd27aadc30ae5bac9dcf2aa72c3ba316

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply Windows PowerShell 5.1 output showing the fixed installer completes over an existing wrapper, plus fresh-install and latest-stable upgrade coverage with existing settings preserved.
Agent review details

How this fits together

The Windows Git installer verifies the built CLI, formats its command wrapper, and publishes it before continuing with PATH setup and Doctor.

flowchart TD
  A[Windows installer] --> B[Build Git checkout]
  B --> C[Verify CLI]
  C --> D[Format command wrapper]
  D --> E[Publish text file atomically]
  E --> F[PATH setup and Doctor]
Loading

Technical review

Best possible solution:

Retain the existing atomic publisher and correct its backup argument to [NullString]::Value.

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

The existing-wrapper branch on current main passes $null to the .NET string parameter, matching the reported Windows exception and base-failing regression; no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete correction: it restores the intended no-backup replacement without changing publication ownership, wrapper contents, cleanup, or the fresh-file path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5b684035a11e.

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

  • Exact introduced change: The pinned introduction changes only the File.Replace backup argument, adds its explanation, and adds one real-filesystem regression test. (scripts/install.ps1:1871, f461152bbd27)
  • Current main still contains the failing argument: Current main passes $null to File.Replace; Install-OpenClawFromGit calls this publisher after verifying the built CLI. (scripts/install.ps1:1870, 5b684035a11e)
  • Original lifecycle intent: fix(install): avoid success after incomplete lifecycle changes #125992 introduced atomic wrapper publication to preserve the previous working installation until replacement; this PR retains that design. (scripts/install.ps1:1870, 7bc994aee831)
  • Regression coverage: The added test executes the production publisher in PowerShell against an existing file and checks its replacement contents; the body reports failure on base and success on head. (test/scripts/install-ps1.test.ts:141, f461152bbd27)
  • Supplied behavior evidence: The complete body reports the original installer failure and successful direct File.Replace substitution on Windows Server 2025 with PowerShell 5.1.26100, but supplies no after-fix installer completion output; discussion adds no further proof. (f461152bbd27)
  • Review policy and history: Read root, scripts, and test AGENTS.md files and applied the maintainer, simplification, and test-audit guidance; no maintainer-notes directory exists. Feature history identifies the publisher introduction and subsequent Windows installer repairs; deeper follow history ends at an unavailable historical object. (AGENTS.md:1, f461152bbd27)

PR surface

Tests +15, Other +1. Total +16 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 15 0 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 1 +1
Total 2 17 1 +16

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: An observed Windows Git reinstall failure prevents wrapper activation after a successful build and can leave the command pointing at the previous installation.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: An observed Windows Git reinstall failure prevents wrapper activation after a successful build and can leave the command pointing at the previous installation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 22, 2026, 1:24 PM ET / 18:24 UTC.

@steipete
steipete merged commit 8ab2464 into main Nov 22, 2026
115 of 116 checks passed
@steipete
steipete deleted the codex/m25-install-ps1-wrapper-replace branch November 22, 2026 19:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 23, 2026
…mmand wrapper (openclaw#203588)

Windows PowerShell passes $null to a .NET string parameter as an empty string, so File.Replace(temp, wrapper, $null) in Publish-TextFileAtomically rejected the backup path ('The path is not of a legal form') whenever install.ps1 ran over an existing ~\.local\bin\openclaw.cmd. The build finished but install.ps1 exited 1 and left the previous wrapper in place. Pass [NullString]::Value instead.

Co-authored-by: Peter Steinberger <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…mmand wrapper (#203588)

Windows PowerShell passes $null to a .NET string parameter as an empty string, so File.Replace(temp, wrapper, $null) in Publish-TextFileAtomically rejected the backup path ('The path is not of a legal form') whenever install.ps1 ran over an existing ~\.local\bin\openclaw.cmd. The build finished but install.ps1 exited 1 and left the previous wrapper in place. Pass [NullString]::Value instead.

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 8ab2464)

Release adaptation: test conflict only. Dropped the neighboring drive-root Git checkout test from main (belongs to a separate change not on this branch); kept only the #203588 wrapper-replacement test.

Intake: P1, suggested as a baseline-applicable companion by the update-windows lane; baseline scripts/install.ps1 still passes $null as the File.Replace backup path. Follow-ups at pinned main 665c286: none.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…it updates (#203247)

* fix(update): admit Git-to-npm switch back and repoint the Windows installer wrapper

A Git release install leaves the npm package forwarding to its launcher, but
the executor's occupied-slot check only accepted a package path that resolves
to the installation, so switching back to npm failed with 'Occupied slot does
not resolve to its original installation.' Reserve this install's exact
forwarding package, the same ownership proof destination admission uses.

install.ps1 wrote the Git wrapper as dist\\entry.js (a literal double
backslash), which the updater's exact match never recognized, so Windows Git
installs kept running the checkout's installer-time build from PATH. Match the
wrapper's entry by normalized Windows path and write single backslashes.

Refs #200578

* fix(update): admit the forwarding package only for its own Git install's executor

Refs #200578

* fix(update): rewrite the Windows Git wrapper so the running cmd.exe exits cleanly

cmd.exe rereads a running batch file at its saved byte offset. openclaw update
usually runs through the wrapper it rewrites, so after the update returned cmd
resumed inside the new command line and the update exited 1 with 'The system
cannot find the path specified.' Pad the new wrapper so the old length lands on
an exit line that keeps the update's exit code.

Drop the npm switch-back slot admission: package publication recovery also
requires the executor's installation to be the npm directory, so the switch
back needs a root decision in the package update owner, not a slot exception.

Refs #200578

* fix(update): leave a wrapper that already runs the release launcher unchanged

Refs #200578

(cherry picked from commit 9809b28)

Release adaptation: Keep only normalized install paths and recognition of the owned stable wrapper when its legacy entry path contains repeated separators. Exclude resident launcher and its retirement rewrite.

Companion audit: PR #203247 is the source. #203588 atomic replacement is already present via NullString.Value; later memory gating is out of scope.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XS 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