wsl --unregister Triggers Unhandled Exception, Orphans Windows Terminal fragment
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.
- 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 - Sign out, then sign back in.
- Note: This removes the local FSLogix profile, which then is recreated at next sign in.
- 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:
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
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'.
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.
/logs
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'.
/emailed-logs
Diagnostic information
Found '/emailed-logs', adding tag 'emailed-logs'