Repository navigation
Closed
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateThis issue is about session, memory, transcript, context, or agent state drift.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
Description
Summary
Choosing Yes to "remove the OpenClaw local WSL gateway" during uninstall can report failure after the gateway is already gone, and can leave stale gateway state behind. scripts/Uninstall-LocalGateway.ps1 uses two names that PowerShell reserves as read-only automatic variables, so two of its helpers never work.
Cause
| Location | Code | Effect |
|---|---|---|
Test-LocalGatewayUrl (line 282, since #591) |
$host = $uri.Host.ToLowerInvariant() |
Throws Cannot overwrite variable Host. The surrounding catch returns $false, so every URL is classified as not local. |
Expand-ExecApprovalsHomePath (line 185, since #1051) |
param([string]$Path, [string]$Home) |
Throws Cannot overwrite variable Home on every call. It is only called when OPENCLAW_STATE_DIR is set. |
The same $Home parameter is copied in scripts/validate-wsl-gateway-uninstall.ps1:237.
What users see
OPENCLAW_STATE_DIRset in the environment: the cleanup that throws runs afterwsl --unregister. The distro is deleted, the script exits 1, and the uninstaller shows "OpenClaw could not remove the local WSL gateway". The gateway record, root device tokens andexec-approvals.jsonstay on disk. From the script's flow, Retry cannot succeed because it reaches the same throw.- Older local gateway record without
setupManagedDistroName: the script prints "removed successfully", but the record stays ingateways.jsonasactiveIdand its identity directory stays. Companion then points at a gateway that no longer exists. isLocal: falserecord with a loopback URL: it is treated as external, so root device tokens are kept. The README says they are cleared unless an external record remains.
Reproduce
I ran the real script under Windows PowerShell 5.1 on main a4dd026 (Windows 11 x64, build 26200) against a throwaway empty distro from wsl --import, with OPENCLAW_STATE_DIR set:
distro registered before uninstall script: True
script exit code: 1
script output: WARNING: Cannot overwrite variable Home because it is read-only or constant.
distro registered after uninstall script: False
gateways.json ids left: [managed]
identity dir left: True
root tokens left: True
legacy exec-approvals.json left: True
result.json: succeeded=False message=Cannot overwrite variable Home because it is read-only or constant.
The two root causes alone reproduce in any Windows PowerShell 5.1 or PowerShell 7 session:
function A { param([string]$Home) }; A 'x'
# Cannot overwrite variable Home because it is read-only or constant.Notes
- I did not run this through the full Inno uninstaller or with a real Gateway inside the distro. The dialog text and Retry behavior above come from reading
installer.issand the script. - I found no existing issue or PR for this. PR fix(setup): delete only generated uninstall children #1521 (
fix(setup): delete only generated uninstall children) edits the same file but not these lines.
I have a fix with regression tests ready and will open a PR.
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateThis issue is about session, memory, transcript, context, or agent state drift.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Oct 31, 2026
Codex review: this still needs some work.
Summary
Current main still contains both PowerShell variable collisions, and the author’s open fixing PR explicitly closes this issue.
Reproducibility: Current source establishes both reserved-variable failures and their cleanup consequences; the reporter also supplies Windows PowerShell 5.1 output, but this review ran no reproduction or tests.
Next step
Review the linked fix PR and verify successful cleanup plus in-product retry through the Inno uninstaller before this issue closes.
Security
None.
Review details
Best possible solution:
Complete the linked repair with idempotent cleanup and a working in-product retry that needs no manual state edits.
Do we have a high-confidence way to reproduce the issue?
Current source establishes both reserved-variable failures and their cleanup consequences; the reporter also supplies Windows PowerShell 5.1 output, but this review ran no reproduction or tests.
Is this the best way to solve the issue?
Renaming the colliding variables and covering production helpers under Windows PowerShell 5.1 is a focused repair; the linked PR already owns it.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against a4dd026cc5f8.
Label changes
Label changes:
P0: The ordinary uninstall flow can delete the gateway, fail its cleanup, and offer a Retry that repeats the same failure without an in-product recovery path.impact:session-state: Legacy local gateway records and activeId can remain pointed at an unregistered distro.impact:ux-release-blocker: Recovering the requested clean uninstall requires environment or state changes outside the uninstall UI.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:linked-pr-open: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.Label justifications:
P0: The ordinary uninstall flow can delete the gateway, fail its cleanup, and offer a Retry that repeats the same failure without an in-product recovery path.impact:ux-release-blocker: Recovering the requested clean uninstall requires environment or state changes outside the uninstall UI.impact:session-state: Legacy local gateway records and activeId can remain pointed at an unregistered distro.Evidence reviewed
What I checked:
scripts/Uninstall-LocalGateway.ps1:185, a4dd026cc5f8)scripts/Uninstall-LocalGateway.ps1:282, a4dd026cc5f8)installer.iss:685, a4dd026cc5f8)tests/OpenClaw.Tray.Tests/UninstallOnboardingSettingsTests.cs:117, a4dd026cc5f8)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed October 31, 2026, 2:26 PM ET / 18:26 UTC.
fix(setup): local gateway removal fails or leaves stale records durin…