Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 cannot start VS Code #10363

Closed
1 of 2 tasks
brandochn opened this issue Aug 4, 2023 · 21 comments
Closed
1 of 2 tasks

WSL2 cannot start VS Code #10363

brandochn opened this issue Aug 4, 2023 · 21 comments

Comments

@brandochn
Copy link

brandochn commented Aug 4, 2023

Windows Version

Microsoft Windows [Version 10.0.19045.3208]

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.90.1-microsoft-standard-WSL2

Distro Version

Ubuntu-22.04

Other Software

VS code Version: 1.81.0 (system setup)
Commit: 6445d93c81ebe42c4cbd7a60712e0b17d9463e97
Date: 2023-08-02T12:37:13.485Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.19045

Repro Steps

If I tried to open both a file or folder by vs code:

code . or code file.txt

I got the following error:

/mnt/c/Program Files/Microsoft VS Code/bin/code: 61: /mnt/c/Program Files/Microsoft VS Code/Code.exe: Exec format error

Expected Behavior

be able to open a file or folder without errors.

Actual Behavior

I got this error:

/mnt/c/Program Files/Microsoft VS Code/bin/code: 61: /mnt/c/Program Files/Microsoft VS Code/Code.exe: Exec format error

Diagnostic Logs

No response

@martin-rueegg
Copy link

martin-rueegg commented Aug 4, 2023

I have a similar situation. The root cause seems to have been either a Windows Update or Ubuntu update (not sure which).

However, the capability to run windows executables without running them explicitly through /init, has vanished today.

In the startup debug log I can see the following entry:

proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
[FAILED] Failed to set up automount Arbitrar…rmats File System Automount Point.
See 'systemctl status proc-sys-fs-binfmt_misc.automount' for details.

However, systemctl status proc-sys-fs-binfmt_misc.automount does not return anything in particular:

$ systemctl status proc-sys-fs-binfmt_misc.automount
○ proc-sys-fs-binfmt_misc.automount - Arbitrary Executable File Formats File System Automount Point
     Loaded: loaded (/lib/systemd/system/proc-sys-fs-binfmt_misc.automount; static)
     Active: inactive (dead)
   Triggers: ● proc-sys-fs-binfmt_misc.mount
      Where: /proc/sys/fs/binfmt_misc
       Docs: https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html
             https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems

Shortly before the above mentioned error during boot, there are a few more errors:

Welcome to Ubuntu 22.04.2 LTS!

Couldn't move remaining userspace processes, ignoring: Input/output error
[   25.308929] Failed to connect to bus: No such file or directory
[   25.513394] scsi 0:0:0:2: Direct-Access     NVMe     KXG50PNV2T04 NVM 4104 PQ: 0 ANSI: 6
[   25.530352] sd 0:0:0:2: Attached scsi generic sg2 type 0
[   25.531478] sd 0:0:0:2: [sdc] 4000797360 512-byte logical blocks: (2.05 TB/1.86 TiB)
[   25.532809] sd 0:0:0:2: [sdc] Write Protect is off
[   25.533439] sd 0:0:0:2: [sdc] Mode Sense: 0f 00 00 00
[   25.535467] sd 0:0:0:2: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   25.545744]  sdc: sdc1 sdc2 sdc3 sdc4 sdc5
[   25.549952] sd 0:0:0:2: [sdc] Attached SCSI disk
[   25.562617] Failed to connect to bus: No such file or directory
[   25.815706] Failed to connect to bus: No such file or directory
[   26.069414] Failed to connect to bus: No such file or directory
[   26.323978] Failed to connect to bus: No such file or directory
Queued start job for default target Graphical Interface.
-.slice: Failed to migrate controller cgroups from /, ignoring: Input/output error

Also, /proc/sys/fs/binfmt_misc/WSLInterop does not exist!

$ ls -la /proc/sys/fs/binfmt_misc/
total 0
drwxr-xr-x 2 root root 0 Aug  4 14:28 .
dr-xr-xr-x 1 root root 0 Aug  4 14:28 ..
-rw-r--r-- 1 root root 0 Aug  4 14:29 python3.10
--w------- 1 root root 0 Aug  4 14:28 register
-rw-r--r-- 1 root root 0 Aug  4 14:28 status

The setting can be set with

$ sudo su -
# echo ":WSLInterop:M::MZ::/init:" > /proc/sys/fs/binfmt_misc/register

which makes the file appear:

 $ ls -la /proc/sys/fs/binfmt_misc/
total 0
drwxr-xr-x 2 root root 0 Aug  4 14:28 .
dr-xr-xr-x 1 root root 0 Aug  4 14:28 ..
-rw-r--r-- 1 root root 0 Aug  4 17:47 WSLInterop
-rw-r--r-- 1 root root 0 Aug  4 14:29 python3.10
--w------- 1 root root 0 Aug  4 17:47 register
-rw-r--r-- 1 root root 0 Aug  4 14:28 status

$ cat /proc/sys/fs/binfmt_misc/WSLInterop
enabled
interpreter /init
flags:
offset 0
magic 4d5a

And CMD.EXE can now be run:

$ /mnt/c/Windows/System32/cmd.exe /c ver
'\\wsl.localhost\Ubuntu\home\mdr\projects\humhub\htdocs'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.

Microsoft Windows [Version 10.0.19045.3271]

However, this seems to fix only part of the issue. But may be helping in getting to the source of the problem.

Btw, #10359 seems to be the same issue.

@martin-rueegg
Copy link

I have a similar situation. The root cause seems to have been either a Windows Update or Ubuntu update (not sure which).

My recent Ubuntu updates. The last one before the afore mentioned was:

Start-Date: 2023-07-31  09:17:10
Commandline: apt upgrade
Requested-By: mdr (1574)
Upgrade: yaru-theme-icon:amd64 (22.04.4, 22.04.5), gnome-control-center-faces:amd64 (1:41.7-0ubuntu0.22.04.6, 1:41.7-0ubuntu0.22.04.7), libldap-common:amd64 (2.5.14+dfsg-0ubuntu0.22.04.2, 2.5.15+dfsg-0ubuntu0.22.04.1), ldap-utils:amd64 (2.5.14+dfsg-0ubuntu0.22.04.2, 2.5.15+dfsg-0ubuntu0.22.04.1), libmysqlclient21:amd64 (8.0.33-0ubuntu0.22.04.2, 8.0.33-0ubuntu0.22.04.4), libldap-2.5-0:amd64 (2.5.14+dfsg-0ubuntu0.22.04.2, 2.5.15+dfsg-0ubuntu0.22.04.1), firefox:amd64 (116.0+build1-0ubuntu0.22.04.1~mt2, 116.0+build2-0ubuntu0.22.04.1~mt1), yaru-theme-sound:amd64 (22.04.4, 22.04.5), yaru-theme-gtk:amd64 (22.04.4, 22.04.5), gnome-control-center-data:amd64 (1:41.7-0ubuntu0.22.04.6, 1:41.7-0ubuntu0.22.04.7), gnome-control-center:amd64 (1:41.7-0ubuntu0.22.04.6, 1:41.7-0ubuntu0.22.04.7), yaru-theme-gnome-shell:amd64 (22.04.4, 22.04.5)
End-Date: 2023-07-31  09:17:23

Which I can ensure is not the cause as I have rebooted the host system between 2023-07-31 09:17:23 and 2023-08-03 09:44:37.

However, I suspect it might have to do with KB5028244:

image

@martin-rueegg
Copy link

#9353 (comment) indicates that disabling systemd would solve the issue. However, in my case, the issue only appeared today after reboot, while I was already using systemd before.

@martin-rueegg
Copy link

sudo apt purge wslu did not resolve the issue.

@Flydiverny
Copy link

Flydiverny commented Aug 4, 2023

Also tried to nuke wslu earlier today with no luck. Uninstalled it and reinstalled it.

#9353 (comment) indicates that disabling systemd would solve the issue. However, in my case, the issue only appeared today after reboot, while I was already using systemd before.

Based on this I just tried to disable systemd, which I've also been having enabled for a really long time. But I don't really depend on it. VSCode launches again however still get some weird errors on some commands.

Enabling systemd again causes issues again:

❯ wsl.exe --shutdown
exec: Failed to execute process: '/mnt/c/windows/system32/wsl.exe' the file could not be run by the operating system.

which works fine before, or when I disable systemd.. 🤔

Seems like this has broken for a bunch of people during the last day.

wsl.exe --version
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1992

I do not have any recent windows updates, everything was working normally the day before this post and in between I had a reboot. I've now also tried the prerelease version of WSL for science but no luck 😄

@martin-rueegg
Copy link

Since this might be a regression (by WSL or Ubuntu) that potentially is going to affect more and more people, I'm just trying to get some attention: @DHowett, @craigloewen-msft. Thanks!

@renanlido
Copy link

Hy guys, i have the same issue

🤞 code . /mnt/c/Users/myUser/AppData/Local/Programs/Microsoft VS Code/bin/code: 61: /mnt/c/Users/myUser/AppData/Local/Programs/Microsoft VS Code/Code.exe: Exec format error

😫

@younes0
Copy link

younes0 commented Aug 6, 2023

@martin-rueegg same situation here, also I can't run windows executables from WSL anymore

Failed to execute process '/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe'. Reason:
exec: unknown error (errno was 8)
The file '/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe' is marked as an executable but could not be run by the operating system.

@elsaco
Copy link

elsaco commented Aug 6, 2023

@younes0 look for /proc/sys/fs/binfmt_misc/WSLInterop file. If missing, that's the issue.

@younes0
Copy link

younes0 commented Aug 6, 2023

@elsaco I couldn't check, I removed the KB5028244 Windows Update and had to turn on again WSL & VM Machine as mentionned on https://superuser.com/a/1736464/256461
Everything is working now. I suspended Windows Updates for now as an annoying workaround

But you must be right, I managed to exec Windows executables when KB5028244 was installed by following this solution : https://stackoverflow.com/a/76826327/822837

@renanlido
Copy link

The solution for my problem was opened /etc/wsl.conf and change the line systemd=true to #systemd=true

I hope this help you!

@younes0
Copy link

younes0 commented Aug 6, 2023

@renanlido thanks but then you disable systemd which I require in my setup

@elsaco
Copy link

elsaco commented Aug 6, 2023

WSLInterop is hardcoded into init process and is supposed to add /proc/sys/fs/binfmt_misc/WSLInterop to the filesystem:

 [elsaco@fedora ~]$ strings /init | grep binfmt
<3>WSL (%d) ERROR: %s:%u: binfmt registration failed %d
/proc/sys/fs/binfmt_misc/register
/proc/sys/fs/binfmt_misc
<3>WSL (%d) ERROR: %s:%u: open /proc/sys/fs/binfmt_misc/register failed %d
binfmt_misc
[elsaco@fedora ~]$ strings /init | grep WSLInterop
:WSLInterop:M::MZ::/init:P
:WSLInterop:M::MZ::/init:FP

And it does, on distros that don't have systemd-udev package installed. This package has systemd-binfmt.service that overrides /proc/sys/fs/binfmt_misc/ and WSLInterop file disappears:

Starting systemd-binfmt.service - Set Up Additional Binary Formats...

The other unit file, proc-sys-fs-binfmt_misc.automount refuses to run:

proc-sys-fs-binfmt_misc.automount: Path /proc/sys/fs/binfmt_misc is already a mount point, refusing start.
[FAILED] Failed to set up automount proc-sys…rmats File System Automount Point.
See 'systemctl status proc-sys-fs-binfmt_misc.automount' for details.

@chinsoon12
Copy link

Following this
#8952 (comment)

resolved the below for me
/mnt/c/Program Files/Microsoft VS Code/bin/code: 61: /mnt/c/Program Files/Microsoft VS Code/Code.exe: Exec format error

@einarpersson
Copy link

einarpersson commented Aug 7, 2023

I started seeing this today. Very disrupting. 😢

Microsoft Windows [Version 10.0.19044.3086]
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19044.3086
Linux version 5.15.90.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Jan 27 02:56:13 UTC 2023
Release:        22.04

Re: @elsaco

❯ ls /proc/sys/fs/binfmt_misc
python3.10  register  status

Edit: this resolved it for me as well #8952 (comment)
(however, a proper fix should be implemented)

@rihards-simanovics
Copy link

rihards-simanovics commented Aug 7, 2023

this has resolved the issue on my wsl: #8952 (comment)

fyi, this is the error I was getting as well:
/mnt/c/Program Files/Microsoft VS Code/bin/code: 61: /mnt/c/Program Files/Microsoft VS Code/Code.exe: Exec format error

@emeric-martineau
Copy link

In my case, I need to remove ~/.vscode* folders to slove this issue.

@brandochn
Copy link
Author

In my case following this:

But you must be right, I managed to exec Windows executables when KB5028244 was installed by following this solution : https://stackoverflow.com/a/76826327/822837

Resolved the issue.

@OneBlue
Copy link
Collaborator

OneBlue commented Aug 8, 2023

/dupe #8843

@microsoft-github-policy-service
Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread.

Thanks for your report!

@abrahamprz
Copy link

@elsaco I couldn't check, I removed the KB5028244 Windows Update and had to turn on again WSL & VM Machine as mentionned on https://superuser.com/a/1736464/256461 Everything is working now. I suspended Windows Updates for now as an annoying workaround

But you must be right, I managed to exec Windows executables when KB5028244 was installed by following this solution : https://stackoverflow.com/a/76826327/822837

This also worked for me, I also wasn't able to run explorer.exe, but that comment fix it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests