Open fonnesbeck opened 4 years ago
Try using wsl
command instead.
This gives me the same error, unfortunately.
If I do open a Debian instance directly, it does start up without error, and everything appears to be mounted correctly, so its curious why wsl
and bash
fail as they do.
Bash command is deprecated so if it breaks, no big deal. But wsl command should work. Try re-installing the VMM feature and see if that helps
Are you referring to HyperV?
No. That is the feature that enables WSL2.
I have that quite frequently, especially if i start WSL very quickly after a reboot. What helps usually: wsl --shutdown
In my case, this was caused by having the "experimental" WSL2 + Docker Desktop integration enabled.
The "default distro" was one of the "distros" Docker installs. wsl -l
to discover this and wsl -d <myDistro>
to explicitly select the distro "fixed" my problem. I will be changing the default and seeing how that goes too.
@kevin-david Your way fixed it for me as well. Thanks!
For everyone's convenience, the command to set the default is wsl -s <myDistro>
.
Success for me:
Credit to @kevin-david for pointing out that the default distro needed setting
In my case, this was caused by having the "experimental" WSL2 + Docker Desktop integration enabled.
The "default distro" was one of the "distros" Docker installs.
wsl -l
to discover this and(should be:wsl -d <myDistro>
wsl -s <myDistro>
- this actually set the distro in my case ) to explicitly select the distro "fixed" my problem. I will be changing the default and seeing how that goes too.
Credit to @stevegore for advising on the wsl option switch -s
to use to set the default distro:
command to set the default is
wsl -s <myDistro>
.
Summary
Yes this helped me. My "default distro" was docker-desktop-data
of all things! What the hell is docker-desktop-data
and why would WSL2 think that was a distro?! So I changed it to Ubuntu
and this solved the issue.
Detail
See my Windows PowerShell (PS) terminal excerpts below.
PS > wsl -l
Windows Subsystem for Linux Distributions:
docker-desktop-data (Default)
Ubuntu
docker-desktop
So I changed this to Ubuntu
PS > wsl -s Ubuntu
Then I verified that the default was now still Ubuntu
, and it was:
PS > wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
docker-desktop-data
docker-desktop
PS >
Then I quit any VSCode windows running, deleted .vscode-server
in Ubuntu terminal (so it would rebuild it cleanly on rerunning vscode later after the above fix) And then I shutdown WSL2:
wsl --shutdown
Then following this, as expected, I got a notification from Docker Desktop about unexpectedly closed and would I like to restart, with a button to restart. This was to be expected following the shutdown command above. So I did this - clicked restart for docker desktop and waited for the little docker whale and cargo to stop animating and then ran Ubuntu again.
And now successful: Then I typed code
in the Ubuntu terminal. Visual Studio Code fired up and in the bottom left corner, reassuringly: "WSL: Ubuntu" showed.
Background
Before this solution I had seen this error in the terminal log in vscode:
VS Code Server for WSL closed unexpectedly
and couldn't determine if the vscode server running.
Other things I had done to resolve this issue:
wsl -l
had reported the default as not is but docker-desktop-data
! )Including vscode log output for informational purposes and seo to help others get to this issue solutions to help them:
[2022-08-15 14:54:13.410] Resolving wsl+docker-desktop-data, resolveAttempt: 1
[2022-08-15 14:54:13.744] Starting VS Code Server inside WSL (wsl2)
[2022-08-15 14:54:13.744] Extension version: 0.66.3
[2022-08-15 14:54:13.744] Windows build: 22000. Multi distro support: available. WSL path support: enabled
[2022-08-15 14:54:13.744] No shell environment set or found for current distro.
[2022-08-15 14:54:13.871] WSL daemon log file:
[2022-08-15 14:54:13.872] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:13.988] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:13.988]
[2022-08-15 14:54:13.989] Launching C:\WINDOWS\System32\wsl.exe -d docker-desktop-data sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 6d9b74a70ca9c7733b29f0456fd8195364076dda stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=455946950-893323131-2587450687-799670964 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2022-08-15 14:54:14.107] VS Code Server for WSL closed unexpectedly.
[2022-08-15 14:54:14.107] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2022-08-15 14:54:14.118] WSL Daemon exited with code 0
[2022-08-15 14:54:21.089] Resolving wsl+docker-desktop-data, resolveAttempt: 2
[2022-08-15 14:54:21.149] Starting VS Code Server inside WSL (wsl2)
[2022-08-15 14:54:21.149] Extension version: 0.66.3
[2022-08-15 14:54:21.149] Windows build: 22000. Multi distro support: available. WSL path support: enabled
[2022-08-15 14:54:21.150] No shell environment set or found for current distro.
[2022-08-15 14:54:21.323] WSL daemon log file:
[2022-08-15 14:54:21.325] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:21.470] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:21.470]
In my case, this was caused by having the "experimental" WSL2 + Docker Desktop integration enabled.
The "default distro" was one of the "distros" Docker installs.
wsl -l
to discover this andwsl -d <myDistro>
to explicitly select the distro "fixed" my problem. I will be changing the default and seeing how that goes too.
Oh!After change the defaluft wsl to ububtu,it works well now .Thank you so much!
在我的情况下,这是由于启用了“实验性”WSL2 + Docker 桌面集成而导致的。 “默认发行版”是 Docker 安装的“发行版”之一。 以发现这一点并明确选择发行版“修复”我的问题。我将更改默认值,看看情况如何。
wsl -l
wsl -d`` Oh!After change the defaluft wsl to ububtu,it works well now .Thank you so much!
That was the problem on my side as well!
To fix:
wsl -l
wsl -s Ubuntu
wsl -l
i've doing something wrong command that delete docker-desktop-data
but i found solution fot this prolem. do this :
And start docker-desktop manually and the docker-desktop will using Ubuntu for wsl
hope this help
None of the above work... is there any more recent workaround for 2023? I've build an image off ubi8 or rockylinux8 but I am getting the same error after importing it into WSL2.
FROM rockylinux/rockylinux:8.8
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
RUN <<EOF cat >> /etc/wsl.conf
[boot]
systemd=true
EOF
Yield:
<3>WSL (11) ERROR: CreateProcessEntryCommon:370: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:374: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:577: execvpe /bin/sh failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:586: Create process not expected to return
@totszwai , I was having the same error. Even after applying the solutions found here, I still had the same error as you. I solved it by uninstalling and reinstalling the WSL extension from VScode. I discovered that VScode was still pointing to the distro created by docker-desktop, despite changing it as stated here, so uninstalling and reinstalling corrected this. Also, restart vscode. or even your entire system. I hope this works.
For everyone struggling, I've been in this place, and the steps I followed:
wsl -s <myDistro>
by running wsl -l (e.g. Ubuntu you should fond the default set to Ubuntu)auth required pam_shells.so
withauth sufficient pam_shells.so
then exit
and rerun wsl
I hope you find this helpful
In my case, this was caused by having the "experimental" WSL2 + Docker Desktop integration enabled.
The "default distro" was one of the "distros" Docker installs.
wsl -l
to discover this andwsl -d <myDistro>
to explicitly select the distro "fixed" my problem. I will be changing the default and seeing how that goes too.
Thanks, I installed wsl2 with Docker and forgot install distro directly. Make wsl --install
to install Ubuntu latest version by default.
On my side, the error is linked to the multipartition on the HDD usb :
[ 1350.756536] scsi 0:0:0:3: Direct-Access Seagate BUP RD 0108 PQ: 0 ANSI: 6 [ 1350.763093] sd 0:0:0:3: Attached scsi generic sg3 type 0 [ 1350.764411] sd 0:0:0:3: [sdd] 7814037167 512-byte logical blocks: (4.00 TB/3.64 TiB) [ 1350.764911] sd 0:0:0:3: [sdd] 4096-byte physical blocks [ 1350.765980] sd 0:0:0:3: [sdd] Write Protect is off [ 1350.766278] sd 0:0:0:3: [sdd] Mode Sense: 0f 00 00 00 [ 1350.767942] sd 0:0:0:3: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 1350.768448] sd 0:0:0:3: [sdd] Optimal transfer size 33553920 bytes not a multiple of physical block size (4096 bytes) [ 1350.859538] sdd: sdd1 sdd2 [ 1350.891833] sd 0:0:0:3: [sdd] Attached SCSI disk [ 1350.993263] WSL (2377): Detected (null) filesystem for device: /dev/sdd [ 1350.994116] WSL (2377) ERROR: UtilMount:1626: mount(/dev/sdd, /mnt/wsl/PHYSICALDRIVE1, (null) [ 1350.994118] , 0x0, ) failed 22
I must do a manual mount in WSL2.
For me, restarting the subsystem did the job
wsl -l -v
to find the default distro:
Ubuntu Running 2
* docker-desktop Stopped 2
docker-desktop-data Stopped 2
docker-desktop
was set as default. Run wsl --set-default {YOUR_DISTRO}
YOUR_DISTRO
is running like in my case.wsl -t YOUR_DISTRO
Here's how I fixed mine:
wsl -l
to find which distro is currently the default distrodocker-desktop
wsl --set-default Ubuntu
as the default WSL distributionyes, if you have Docker installed in your OS, then docker-desktop-data becomes the default distro which does not work with bash or wsl. It works fine after making Ubuntu the default distro by command wsl -d Ubuntu.
After switching the default WSL to Ubuntu, everything is functioning properly now. Thank you very much!
wsl -d
In my case, this was caused by having the "experimental" WSL2 + Docker Desktop integration enabled.
The "default distro" was one of the "distros" Docker installs.
wsl -l
to discover this andwsl -d <myDistro>
to explicitly select the distro "fixed" my problem. I will be changing the default and seeing how that goes too.
please how do i use
'''
wsl -d
Environment
Steps to reproduce
After installing Ubuntu or Debian on WSL2, attempt to use bash by running
bash
from powershell.Expected behavior
This should start up bash and return a bash prompt.
Actual behavior
The
bash
command fails with the following error:Following these instructions, here is the relevant output from
dmesg
: