Skip to content

Uninstall leaves behind empty directories in %LOCALAPPDATA% #467

@indierawk2k2

Description

@indierawk2k2

Bug

After running the full uninstall flow (WSL uninstall from tray app followed by MSIX uninstall), two empty directories remain on disk:

  1. %LOCALAPPDATA%\OpenClawTray\wsl\ - empty folder (parent of where the VHD lived)
  2. %LOCALAPPDATA%\OpenClawTray\ - now-empty parent directory

Repro Steps

  1. Install OpenClaw Tray (MSIX, v0.4.4.0)
  2. Run through easy-button setup (WSL distro provisions successfully)
  3. Use tray app - Settings - Remove Local Gateway (WSL uninstall completes)
  4. Uninstall the MSIX package via Windows Settings
  5. Inspect %LOCALAPPDATA%\OpenClawTray\

Expected

%LOCALAPPDATA%\OpenClawTray\ should not exist after uninstall.

Actual

%LOCALAPPDATA%\OpenClawTray\wsl\ remains as an empty directory. The parent OpenClawTray\ folder also persists.

Root Cause

In the 13-step uninstall engine (LocalGatewayUninstall.cs), Step 7 deletes the VHD directory at %LOCALAPPDATA%\OpenClawTray\wsl\OpenClawGateway\ but does not clean up the parent wsl\ directory. After all steps complete, the OpenClawTray\ folder is left behind because it still contains the empty wsl\ subdirectory.

Suggested Fix

After Step 7 removes the VHD subdirectory, also remove the parent wsl\ directory if it is empty. Then, as a final cleanup step, remove the %LOCALAPPDATA%\OpenClawTray\ directory itself if it is empty (i.e., no logs, result files, or other artifacts remain).

// After deleting wsl\OpenClawGateway:
var wslDir = Path.Combine(localAppData, "OpenClawTray", "wsl");
if (Directory.Exists(wslDir) && !Directory.EnumerateFileSystemEntries(wslDir).Any())
{
    Directory.Delete(wslDir);
}

// Final cleanup - remove OpenClawTray dir if empty
var appDir = Path.Combine(localAppData, "OpenClawTray");
if (Directory.Exists(appDir) && !Directory.EnumerateFileSystemEntries(appDir).Any())
{
    Directory.Delete(appDir);
}

The validation script (scripts/validate-wsl-gateway-uninstall.ps1) should also be updated to assert that the wsl\ parent directory is absent after uninstall.

Additional Note

A separate empty temp directory at %LOCALAPPDATA%\Temp\WSLDVCPlugin\OpenClawGateway\ also persists, but since this is in the system Temp folder it is lower priority and will be cleaned up by normal temp maintenance.

Environment

  • Windows 11
  • OpenClaw Tray v0.4.4.0 (MSIX, test-signed)
  • WSL2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions