openclaw - ✅(Solved) Fix [Bug]: Uninstall deletes workspace inside .openclaw even when "delete workspace" is unchecked [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75052Fetched 2026-05-01 05:38:40
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
2
Timeline (top)
referenced ×5cross-referenced ×2commented ×1labeled ×1

When uninstalling OpenClaw, selecting “delete config files” but not selecting “delete workspace files” deletes the entire .openclaw directory, causing workspaces stored under .openclaw to be deleted.

Error Message

The uninstall behavior appears inconsistent with the UI options. If “delete workspace files” is unchecked, uninstall should either preserve workspace directories under .openclaw or warn the user that deleting .openclaw will also remove nested workspaces.

Root Cause

Severity: High, because workspace files may be deleted unexpectedly

Fix Action

Fixed

PR fix notes

PR #75061: fix: preserve workspaces during state-only uninstall

Description (problem / solution / changelog)

Summary

  • preserve configured workspace directories when openclaw uninstall --state removes a parent state directory
  • keep destructive workspace deletion behavior when --workspace/--all is selected
  • document the CLI behavior and warn manual uninstall users about rm -rf ~/.openclaw when workspaces live inside state

Fixes #75052.

Root cause

removeStateAndLinkedPaths removed the whole state directory recursively. The default workspace lives under ~/.openclaw/workspace, so a state-only uninstall could delete workspace files even when workspace deletion was not selected.

Validation

  • pnpm test src/commands/uninstall.test.ts src/commands/cleanup-utils.test.ts src/commands/reset.test.ts src/commands/agents.delete.test.ts
  • pnpm exec oxfmt --check --threads=1 src/commands/uninstall.ts src/commands/cleanup-utils.ts src/commands/uninstall.test.ts src/commands/cleanup-utils.test.ts src/commands/reset.test.ts docs/cli/uninstall.md docs/install/uninstall.md
  • git diff --check
  • pnpm check:changed

Changed files

  • docs/cli/uninstall.md (modified, +1/-0)
  • docs/install/uninstall.md (modified, +3/-0)
  • src/commands/cleanup-utils.test.ts (modified, +37/-0)
  • src/commands/cleanup-utils.ts (modified, +101/-6)
  • src/commands/uninstall.test.ts (modified, +38/-0)
  • src/commands/uninstall.ts (modified, +1/-1)

PR #75062: fix(uninstall): preserve workspace-inside-state when only state scope selected

Description (problem / solution / changelog)

Summary

Fixes #75052.

When a user's workspace directory lives inside the state dir (e.g. ~/.openclaw/workspaces/main) and they run openclaw uninstall selecting only the State + config scope (not Workspace), the entire state dir was deleted anyway — taking the workspace with it.

Root cause: removeStateAndLinkedPaths always called removePath(stateDir) unconditionally, even when a workspace-to-preserve was nested inside it.

Fix: Added workspaceDirsToPreserve option to removeStateAndLinkedPaths. Before deleting the state dir, the function checks whether any preserved workspace lives inside it. If so, it logs a warning and skips the state dir deletion. The uninstall command passes workspaceDirs as the preserve list when the workspace scope was NOT selected.

Changes

  • src/commands/cleanup-utils.ts: add workspaceDirsToPreserve opt + containment guard before removePath(stateDir)
  • src/commands/uninstall.ts: pass workspaceDirsToPreserve when workspace scope not selected
  • src/commands/cleanup-utils.test.ts: regression test for the skip path + dry-run assertion

Test plan

  • pnpm vitest run src/commands/cleanup-utils.test.ts — 6/6 pass (including new regression)
  • Regression: removeStateAndLinkedPaths with workspaceDirsToPreserve=[<path inside stateDir>] logs "Skipping state dir removal" and does NOT emit [dry-run] remove <stateDir>
  • Existing tests unchanged (removes state normally when no preserve list, removes oauth when outside state)

🤖 Generated with Claude Code

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/commands/cleanup-utils.test.ts (modified, +69/-0)
  • src/commands/cleanup-utils.ts (modified, +50/-5)
  • src/commands/uninstall.ts (modified, +4/-1)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When uninstalling OpenClaw, selecting “delete config files” but not selecting “delete workspace files” deletes the entire .openclaw directory, causing workspaces stored under .openclaw to be deleted.

Steps to reproduce

  1. Create or use a workspace located under the .openclaw directory.
  2. Uninstall OpenClaw.
  3. Check the option to delete configuration files.
  4. Do not check the option to delete workspace files.
  5. Complete the uninstall process.
  6. Observe that the .openclaw directory is deleted, including the workspace inside it.

Expected behavior

Only configuration files should be deleted. Workspace files should be preserved when the “delete workspace files” option is not selected.

Actual behavior

The entire .openclaw directory is deleted, including workspace files located inside it, even though the workspace deletion option was not selected.

OpenClaw version

new

Operating system

ubuntu 22

Install method

No response

Model

None

Provider / routing chain

None

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: Users whose workspace is stored under the .openclaw directory

Severity: High, because workspace files may be deleted unexpectedly

Frequency: Reproducible when the workspace is inside .openclaw and config deletion is selected during uninstall

Consequence: User workspace data may be lost despite the workspace deletion option being unchecked

Additional information

The uninstall behavior appears inconsistent with the UI options. If “delete workspace files” is unchecked, uninstall should either preserve workspace directories under .openclaw or warn the user that deleting .openclaw will also remove nested workspaces.

extent analysis

TL;DR

The uninstall process should be modified to preserve the .openclaw directory when the "delete workspace files" option is not selected, or to warn the user about the potential data loss.

Guidance

  • Review the uninstall script or code to identify why the entire .openclaw directory is being deleted when only configuration files are selected for deletion.
  • Consider adding a conditional check to preserve the .openclaw directory or its contents when the "delete workspace files" option is not selected.
  • Add a warning or confirmation prompt to inform the user that deleting configuration files may also remove workspace files if they are stored within the same directory.
  • Verify that the uninstall process correctly handles different scenarios, such as when workspaces are stored outside of the .openclaw directory.

Example

No specific code example can be provided without knowing the implementation details of the uninstall script or code. However, a possible approach could involve checking the state of the "delete workspace files" option and adjusting the file deletion logic accordingly.

Notes

The current behavior may be due to an oversight in the uninstall script or a misunderstanding of the intended behavior. It is essential to review the code and test different scenarios to ensure the correct functionality.

Recommendation

Apply a workaround by modifying the uninstall script or code to correctly handle the "delete workspace files" option and preserve the .openclaw directory or its contents when necessary. This will prevent unexpected data loss and ensure a more consistent user experience.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Only configuration files should be deleted. Workspace files should be preserved when the “delete workspace files” option is not selected.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Uninstall deletes workspace inside .openclaw even when "delete workspace" is unchecked [2 pull requests, 1 comments, 2 participants]