Repository navigation
fix: let a Windows reinstall replace the existing openclaw command - #203588
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
PR surfaceTests +15, Other +1. Total +16 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 22, 2026, 1:24 PM ET / 18:24 UTC. |
|
Merged via squash.
|
…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]>
…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]>
…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]>
What Problem This Solves
Re-running the Windows installer (
install.ps1) on a machine that already has theopenclawcommand fails at the very end. The build succeeds, then the installer exits withException calling "Replace" with "3" argument(s): "The path is not of a legal form."and leaves the previousopenclaw.cmdwrapper 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.ps1over an existing install now updates theopenclawcommand and finishes successfully.Why This Change Was Made
Publish-TextFileAtomicallyswaps the wrapper with[System.IO.File]::Replace($temporaryPath, $Path, $null). PowerShell passes$nullto a .NETstringparameter as an empty string, andFile.Replacerejects an empty backup path. Passing[NullString]::Valuesends a real null, meaning no backup, which is what the code intended.Evidence
$nullfails with "The path is not of a legal form"; with[NullString]::Valueit replaces the file.install.ps1 -InstallMethod gitover an existing wrapper exited 1 right after a successful build. Seen in the daily update matrix (Windows Git lane re-install).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.