-
Notifications
You must be signed in to change notification settings - Fork 822
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
cannot open explorer.exe/code in WSL2 #8986
Comments
/logs |
Hello! Could you please provide more logs to help us better diagnose your issue? To collect WSL logs, download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
The scipt will output the path of the log file once done. Once completed please upload the output files to this Github issue. Click here for more info on logging Thank you! |
Thank you @lanyuer but unfortunately I'm not seeing any WSL logs in the file you shared. Did you reproduce the issue while the log collection was running ? |
@lanyuer - are you using systemd? Looks like in some situation the binfmt interpreter may be getting unregistered. |
I have the same problem with Visual Studio Code since WSL 0.7 and I have systemd activated: Unfortunately, I cannot use an administrative powershell prompt because our IT has deprived us of our administrative privileges. @benhillis - is there a possibility to register binfmt again? Is this the service
● binfmt-support.service - Enable support for additional executable binary formats After starting the service with ● binfmt-support.service - Enable support for additional executable binary formats Oct 14 16:47:25 xxxxxx systemd[1]: Starting Enable support for additional executable binary formats... But the Thank you! |
Yes, everything is back to normal when I closed systemd in /etc/wsl.conf |
When I set |
Ok - unfortunately there's not going to be a perfect fix until the Linux kernel supports binfmt namespaces. |
Ok, thank you for looking into it. Do you know an approximate time horizon? |
have a look at #8843 |
Brilliant, the fix with WSLInterop.conf is working. Thank you very much. |
I feel like the Ubuntu install for WSL2 should just include the WSLInterop.conf file. That would fix this for all systemd users I believe.... |
So suddenly my WSLInterop.conf file isn't being picked up by the binfmt-support service... I added the WSLInterop.conf file into /usr/lib/binfmt.d The contents look like this:
However, when I run |
I even tried adding the conf file to |
Okay I figured it out, there's TWO things that configure binfmts on Ubuntu... both are systemd services....
If your WSL interop ever breaks you should run the following in this order: sudo systemctl restart systemd-binfmt
sudo systemctl restart binfmt-support This will fix it up and make all of your binfmts registered. I still don't know why this isn't happening when the WSL first starts up. Or what runs that breaks it. |
Unfortunately for me, @bartdorsey's workaround didn't work. However, disabling systemd worked. This didn't happen for me initially and I couldn't reproduce it on fresh installs, so creating a 100% reproduction will be difficult. |
Hey @dead-claudia, some clever people found the solution, by adding one line to the |
I think running Look:
I don't know what I did right, just I followed the instructions I found in this discussion...
And try update WSL2
And I restarted my machine. Now everything works as before... thank you!! |
I had this same issue after 'systemctl halt' (WSL2 Ubuntu 22_04), powershell.exe wouldn't execute, etc. All I had to do was 'wsl --shutdown' and bring it back up and everything started working again, didn't require any further changes for me in this case. |
I am suddenly getting this error with any executable, examples: $ explorer.exe .
-bash: /mnt/c/WINDOWS/explorer.exe: cannot execute binary file: Exec format error
$ code .
/mnt/c/Users/Marco/AppData/Local/Programs/Microsoft VS Code/bin/code: 61: /mnt/c/Users/Marco/AppData/Local/Programs/Microsoft VS Code/Code.exe: Exec format error I did not change anything from yesterday nor fiddle with any configuration, I just ran a regular system update with: sudo apt update; sudo apt upgrade -y; sudo apt autoremove -y Any idea what might have caused this issue and how to fix it? |
I just want to report that I have the same problem as @lackovic . I'm running WSL2 with systemd enabled. I didn't make any change to my system and this error suddenly show up after turning on my computer this morning. |
Same here, I just noticed today that running PE32s didn't work. I have systemd enabled. I know I ran an I re-installed binfmt-support (wasn't enough on its own). In short, this fixed it for me:
Thanks all! |
I ran into this issue this morning. It working fine last night but this morning got that Running the binfmt-support and WSLInterop.conf resolved the issue. @strottie Thank you for the step by step fix. |
Same problem as others .the changes mentioned here works |
Thanks so much, it's working again for me. I have some error output when launching links to my browser.
|
This error appeared out of the blue. And the crazy thing is that it seems to be non-deterministic. Sometimes Windows executables work fine at the beginning of a sesssion in a Linux distribution, and then suddenly after a while they don't work anymore and the Terminating and restarting the Linux distribution sometimes helps and sometimes it doesn't. However, then after a while the error usually occurs again. The solution proposed above (i.e. install |
@strottie solution worked for me. |
Something's just happened out of nowhere. Never had this problem before:
The solution from @strottie helped. For some reason this file |
I had the same error. But after removing docker-desktop and restarting the computer, it disappeared.
|
This issue happens to me every time I start or stop Minikube with docker driver in WSL. Creating the With systemd disabled I could not find a workaround, which suggests to me that creating the WSInterop.conf file is a patch that happens to work with systemd enabled, but it is masking the real problem more than anything. Anyway, thanks for providing a workaround in this thread. It has been extremely helpful. |
I had similar issue and this is my perma workaround that helps in the case that some command (docker in my case) is breaks the interop |
Version
10.0.22000.978
WSL Version
Kernel Version
5.15.68.1
Distro Version
Ubuntu 20.04
Other Software
No response
Repro Steps
explorer.exe .
code .
Expected Behavior
open folder
Actual Behavior
exec: Failed to execute process: '/mnt/c/Windows/explorer.exe' the file could not be run by the operating system.
/mnt/f/Users/mylan/AppData/Local/Programs/Microsoft VS Code/bin/code: line 61: /mnt/f/Users/mylan/AppData/Local/Programs/Microsoft VS Code/Code.exe: cannot execute binary file: Exec format error
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: