An unexpected error was encountered while executing a WSL command

I just watched this video followed all the step, yet the issue persist

I found the solution, it works for me: failed installation - wsl --set-default-version 2 The service cannot be started, either because it is disabled or because it has no enabled devices associated with it - Stack Overflow

That worked for me, thanks

I have fixed the issue by executing these commands in powershell and cmd respectively.

Powershell as admin,

  1. bcdedit /set HypervisorLaunchType auto
  2. shutdown /r /t 0

And it automatically restarted the systems.

Then I encountered wsl error. For this, I opened the cmd and typed,

wsl --update

1 Like

In my case it was because of a docker desktop distribution stuck in an “uninstall” status.

run in cmd “wsl -l -v”
there might be a distribution stuck there with name “docker-desktop” or “docker-desktop-data” or sth similar.

when I ran wsl --unregister docker-desktop-data
I opened docker desktop again and everything was working

I can’t believe it but your tip actually helped me. As You suggested, I’ve wandered through my device manager in System devices category, clicking on every hyper-v related driver, trying to update them or to see if they’re turned off, they all were up to date, but one of them was actually turned off. I enabled it, it automatically restarted my PC and now Docker Desktop is working.
image
One of those was turned off

Continuing the discussion from An unexpected error was encountered while executing a WSL command:

I encountered this same issue and here’s what worked for me

  1. Restart your PC and enter the BIOS settings by tapping ESC.
  2. The Startup Menu pops up with some settings below, click on “BIOS Setup”
  3. Navigate to the “Advanced” and then “System Options” tab.
  4. Look for “Virtualization Technology” or “VTx” and enable it.
  5. Save changes and exit the BIOS settings.

For a steps with pictures represented follow the link to my LinkedIn post below

Troubleshooting to Virtualize for Docker

For Windows user,
Check your .wslconfig file: Look in C:\Users<username>\ for a file named .wslconfig. Open it with a text editor. Look for a line specifying the kernel, it might look something like: kernel=C:\\temp\\myCustomKernel. If you don’t need a custom kernel:

  • Comment out or remove this line
  • Save the file and try running Docker Desktop again
    This helped me solve my issue

it worked for me thx

This work for me, very very thanks!

hey guys , for me this worked

1- even though virtualization is enabled in bios u might wanna toggle it if the hypervisor is grayed like the attached sc

restart> disable virtualization> restart again and enable it > go windows features and turn on all the features including the hyporvisor which is now accessible
2- type hyper v manager in windows search and u ll be able to see a gui app like the screenshot

3- its ok if task manager doesnt show hyper v enabled dont panic!

use the below commands to check if things are smooth.
1- Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All | expected output{FeatureName : Microsoft-Hyper-V-All
DisplayName : Hyper-V
Description : Provides services and management tools for creating and running virtual machines and their
resources.
RestartRequired : Possible
State : Enabled
CustomProperties :
}

2- Get-Service -Name vmcompute | expected output {Status Name DisplayName


Running vmcompute Hyper-V Host Compute Service}

3- make sure u have wsl and ubuntu installed and set to version 2 \wsl --set-default-version 2

Check Ethernet Adapter “vEthernet (Default Switch)” is enabled. Enabling this helped me.

wsl --update worked for me

Thank You very much! This work for me!