I have installed some extension like Dev containers, Remote - SSH, WSL. After VS Code restart I got error message box that complains regarding WSL. How to solve this problem?
[Window Title]
Visual Studio Code
VS Code Server for WSL closed unexpectedly.
Check WSL terminal for more details.
Terminal output:
[2023-06-14 10:27:49.292] Run: C:\Windows\System32\wsl.exe --status
[2023-06-14 10:27:49.324] Resolving wsl+docker-desktop-data, resolveAttempt: 1
[2023-06-14 10:27:49.406] WSL feature installed: true
[2023-06-14 10:27:49.406] Run: C:\Windows\System32\wsl.exe --list --verbose
[2023-06-14 10:27:49.501] Starting VS Code Server inside WSL (wsl2)
[2023-06-14 10:27:49.501] Extension version: 0.79.4
[2023-06-14 10:27:49.501] Windows build: 22621. Multi distro support: available. WSL path support: enabled
[2023-06-14 10:27:49.501] L10N bundle: undefined
[2023-06-14 10:27:49.501] Scriptless setup: false
[2023-06-14 10:27:49.502] No shell environment set or found for current distro.
[2023-06-14 10:27:49.646] WSL daemon log file:
[2023-06-14 10:27:49.650] Probing if server is already installed: if [ -d ~/.vscode-server/bin/4cb974a7aed77a74c7813bdccd99ee0d04901215 ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m
[2023-06-14 10:27:49.651] Run: C:\Windows\System32\wsl.exe -d docker-desktop-data -e sh -c if [ -d ~/.vscode-server/bin/4cb974a7aed77a74c7813bdccd99ee0d04901215 ]; then printf 'install-found '; fi; if [ -f /etc/alpine-release ]; then printf alpine-; fi; uname -m
[2023-06-14 10:27:49.821] Unable to detect if server is already installed: Error: Failed to probe if server is already installed: code: Failed to probe if server is already installed: code: 1, <3>WSL (35) ERROR: CreateProcessEntryCommon:370: getpwuid(0) failed 2
[2023-06-14 10:27:49.821] <3>WSL (35) ERROR: CreateProcessEntryCommon:374: getpwuid(0) failed 2
[2023-06-14 10:27:49.821] <3>WSL (35) ERROR: CreateProcessEntryCommon:577: execvpe sh failed 2
[2023-06-14 10:27:49.821] <3>WSL (35) ERROR: CreateProcessEntryCommon:586: Create process not expected to return
[2023-06-14 10:27:49.821] ,
[2023-06-14 10:27:49.822] Run: C:\Windows\System32\wsl.exe -d docker-desktop-data sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 4cb974a7aed77a74c7813bdccd99ee0d04901215 stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=3430567610-3130869115-3174801786-4290732074 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2023-06-14 10:27:49.995] <3>WSL (38) ERROR: CreateProcessEntryCommon:370: getpwuid(0) failed 2
[2023-06-14 10:27:49.995] <3>WSL (38) ERROR: CreateProcessEntryCommon:374: getpwuid(0) failed 2
[2023-06-14 10:27:49.995] <3>WSL (38) ERROR: CreateProcessEntryCommon:577: execvpe /bin/sh failed 2
[2023-06-14 10:27:49.995] <3>WSL (38) ERROR: CreateProcessEntryCommon:586: Create process not expected to return
[2023-06-14 10:27:49.995] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips

This problem occurs because the distro docker-desktop-data isn't interactive, which means you cannot send any command to this distro. You can find more information about that in this response:
What is the docker-desktop-data distro used for when running docker desktop with the WSL 2 engine
It is necessary to install another distro and set it as the default. Open a command prompt (CMD or PowerShell) as an administrator and type the following command to check the available Linux distros online:
wsl --list --online
Select the distro you prefer, in my case the latest Ubuntu distro. During installation Ubuntu prompts for a new non-root user:
wsl --install -d Ubuntu
Set the new distro as default:
wsl -s Ubuntu
Check if Ubuntu is set as your default distro:
wsl -l -v
You should see an output similar to this:
NAME STATE VERSION
* Ubuntu Stopped 2
docker-desktop-data Stopped 2
docker-desktop Stopped 2
Disclaimer: I assume you have correctly configured WSL on version 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With