WSL: WSL2 cannot start VS Code
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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 21 (1 by maintainers)
In my case following this:
Resolved the issue.
The solution for my problem was opened /etc/wsl.conf and change the line systemd=true to #systemd=true
I hope this help you!
@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 has resolved the issue on my wsl: https://github.com/microsoft/WSL/issues/8952#issuecomment-1572193568
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 errorThis also worked for me, I also wasn’t able to run
explorer.exe, but that comment fix it too.Following this https://github.com/microsoft/WSL/issues/8952#issuecomment-1568212651
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@renanlido thanks but then you disable systemd which I require in my setup
My recent Ubuntu updates. The last one before the afore mentioned was:
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:
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:
However,
systemctl status proc-sys-fs-binfmt_misc.automountdoes not return anything in particular:Shortly before the above mentioned error during boot, there are a few more errors:
Also,
/proc/sys/fs/binfmt_misc/WSLInteropdoes not exist!The setting can be set with
which makes the file appear:
And
CMD.EXEcan now be run: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.