WSL icon indicating copy to clipboard operation
WSL copied to clipboard

wsl --unregister Triggers Unhandled Exception, Orphans Windows Terminal fragment

Open qkflies opened this issue 6 months ago • 4 comments

Windows Version

10.0.22631.5335

WSL Version

2.4.10.0, 2.4.13.0, 2.5.7.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

5.15.167.4-1

Distro Version

Ubuntu 24.04.2 LTS (Noble Numbat) - Canonical WSL root filesystem image

Other Software

FSLogix 2210 hotfix 4 (2.9.8884.27471)

Repro Steps

Assume FSLogix profiles are in use.

  1. Register distribution with vhd location in FSLogix local profile:
    wsl --import Ubuntu-24.04 "$(Join-Path -Path $(Join-Path -Path $($(Get-ChildItem HKCU:\Software\FSLogix\Profiles\).GetValue('LocalProfilePath')) -ChildPath Temp) -ChildPath Ubuntu-24.04)" "C:\WSL\ubuntu2404.tar.gz" --version 2
    
  2. Sign out, then sign back in.
    • Note: This removes the local FSLogix profile, which then is recreated at next sign in.
  3. Attempt to unregister the distribution:
    wsl --unregister Ubuntu-24.04
    

Expected Behavior

The unregister command completes successfully.

Actual Behavior

The unregister command returns the following error:

{Application Error} The exception %s (0x
Error code: Wsl/Service/ERROR_UNHANDLED_EXCEPTION

As a consequence, it appears that a Windows Terminal JSON Fragment Extension is orphaned, requiring manual removal. Otherwise, Windows Terminal shows this error on each launch: Windows Terminal error message: Encountered errors while loading user settings

Encountered errors while loading user settings

Found a profile with an invalid "icon". Defaulting that profile to have no icon. Make sure that when setting an "icon", the value is a valid file path to an image.

Inspecting the directory \Users\$Env:USERNAME\AppData\Local\Microsoft\Windows Terminal\Fragments\Microsoft.WSL\, there is a json file that indeed has the path .profiles[1].icon with a corrupt path of \\\\?\\C:\\Users\\local_$Env:USERNAME\\Temp\\Ubuntu-24.04\\shortcut.ico. Deleting this json file removes the Windows Terminal error.

Diagnostic Logs

No response

qkflies avatar May 29 '25 20:05 qkflies

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

github-actions[bot] avatar May 29 '25 20:05 github-actions[bot]

To clarify the WSL versions reported, I have tested with WSL releases 2.2.4.0, 2.3.24.0, and 2.3.26.0. This bug did not occur until 2.4.x and still appears to be an issue in 2.5.x.

qkflies avatar May 29 '25 20:05 qkflies

/logs

OneBlue avatar May 29 '25 21:05 OneBlue

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

github-actions[bot] avatar Jun 17 '25 16:06 github-actions[bot]

/emailed-logs

qkflies avatar Jun 17 '25 16:06 qkflies

Diagnostic information
Found '/emailed-logs', adding tag 'emailed-logs'

github-actions[bot] avatar Jun 17 '25 16:06 github-actions[bot]