Skip to content

Uninstall leaves behind empty directories in %LOCALAPPDATA% #467

Closed

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

Activity

  1. added
    bug
    on May 19, 2026
  2. shanselman commented on May 19, 2026

    @shanselman
    Collaborator

    Thanks @indierawk2k2 ? this is a good catch and the root-cause analysis looks right. Leaving an empty %LOCALAPPDATA%\OpenClawTray\wsl\ keeps the parent %LOCALAPPDATA%\OpenClawTray\ around after the MSIX is removed, which makes uninstall feel incomplete even though the VHD itself is gone.

    I labeled this as bug. The fix should clean up empty parent directories only when they are truly empty, so we do not remove logs, result files, or any other artifacts the user might still need. The uninstall validation script should also assert the wsl\ parent is gone after the WSL distro/VHD cleanup path.

  3. added a commit that references this issue on May 20, 2026
    bb3d34b
  4. github-actions commented on May 20, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I investigated and implemented the fix described in this issue. The root cause is exactly as @indierawk2k2 identified: Step 5a in LocalGatewayUninstall.cs removes the distro-specific VHD directory but not the wsl\ parent.

    I have opened a draft PR with:

    • Step 5b: deletes %LOCALAPPDATA%\OpenClawTray\wsl\ if empty after Step 5a (non-empty directories are preserved safely)
    • WslParentDirAbsent postcondition so the uninstall engine self-validates the fix
    • Validation script update (validate-wsl-gateway-uninstall.ps1) to assert wsl_parent_dir_absent in postcondition checks
    • 3 unit tests covering the empty→deleted, non-empty→skipped, and already-absent→skipped cases

    The %LOCALAPPDATA%\OpenClawTray\ root itself is left for the MSIX uninstaller to clean up once empty, consistent with the existing approach.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
    
  5. added a commit that references this issue on May 21, 2026
    6946b72
  6. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions