WSL: Interop Issue: unable to find interpreter for launching Windows .exe files using Interop

Environment

Windows build number: Microsoft Windows [Version 10.0.19613.1005] 
Your Distribution version: Release:        18.04
Whether the issue is on WSL 2 and/or WSL 1:Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020

Steps to reproduce

  1. Attempt to run Windows .exe that are in my WSL path: ~$ which code /mnt/c/Users/gfinn/AppData/Local/Programs/Microsoft VS Code/bin/code

~$ code run-detectors: unable to find an interpreter for /mnt/c/Users/gfinn/AppData/Local/Programs/Microsoft VS Code/Code.exe

Expected behavior

Windows executable would launch

Actual behavior

Error message shown above: run-detectors: unable to find an interpreter for /mnt/c/Users/gfinn/AppData/Local/Programs/Microsoft VS Code/Code.exe

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 37 (1 by maintainers)

Most upvoted comments

@jdknox I can fix this problem by executing the following command:

sudo update-binfmts --disable cli

restarting wsl with power shell > wsl --shutdown helped.

I am on a relatively fresh copy of ubuntu 20.04 in wsl2. I noticed it having this issue last night. I do not that I never installed docker inside the wsl environment, and enabled the wsl feature in docker for windows. When running some of the above commands I get these outputs:

❯ mount | grep binfmt_misc
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)

libmono

❯ apt search libmono | grep -i installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libmono-btls-interface4.0-cil/focal,now 6.8.0.105+dfsg-2 amd64 [installed,automatic]
libmono-corlib4.5-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-i18n-west4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-i18n4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-security4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-system-configuration4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-system-core4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-system-numerics4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-system-security4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-system-xml4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]
libmono-system4.0-cil/focal,now 6.8.0.105+dfsg-2 all [installed,automatic]

I know I have been able to run say vscode through wsl before and worked fine. I discoverd the issue when trying to run it again and got the same error

❯ code-insiders .
run-detectors: unable to find an interpreter for /mnt/c/Users/shawn/AppData/Local/Programs/Microsoft VS Code Insiders/Code - Insiders.exe

If I run command in https://github.com/microsoft/WSL/issues/5466#issuecomment-695155716

sudo update-binfmts --disable cli

will that disable running the windows applications from the wsl cli?

EDIT: I tried the above command anyways, and it fixed the issue for me.

Uninstalling the mono-runtime package via sudo apt remove mono-runtime also resolves the issue.

See https://github.com/microsoft/WSL/issues/9257#issuecomment-1352443162

I just wanted to mention I had this same problem, and none of the troubleshooting steps from above added any clues on how to solve. But I had recently apt installed some things and went through those to see what I could see. Turns out nuget added some libmono stuff that broke my interopability. As soon as I removed that package, everything starting working again.

But I would add, the error message is a bit cryptic out-of-context. Maybe it should mention something about WSL for those of us who are plain, old uninitiated mortals?

Permanently solved by uninstalling mono-runtime.

@jdknox I can fix this problem by executing the following command:

sudo update-binfmts --disable cli

This totally worked for me, and the cause for the error was because I had installed something with libmono

I also have the similar issue starting today, I am unable to run any windows related executables. I am using Linux 4.19.121-microsoft-WSL2-standard, Windows 10 20150.1000 Close docker for Windows(WSL2 backend) actually helps me, so it is possibly a docker related issue

@jdknox I can fix this problem by executing the following command:

sudo update-binfmts --disable cli

For future info: After installing “mono-complete” on my WSL2, for dotnet programming in vscode, i had this same issue, and this command fixed it.

To re-apply the fix after WSL reboots, I’ve added this bit among many other hacks into my ~/.profile :

# https://github.com/microsoft/WSL/issues/5466
python.exe --version >/dev/null 2>&1 || \
sudo update-binfmts --disable cli

So it tries to run whatever Windows exe that is supposed to exit quickly and successfully, and if it fails - applies the fix from this thread. Should only happen once per WSL boot and subsequent log-in (which is also parsed when Docker Desktop starts and causes WSL to start).

So, any of:

  1. sudo update-binfmts --disable cli
  2. sudo apt remove mono-runtime https://github.com/microsoft/WSL/issues/9257#issuecomment-1352443162
  3. changing systemd=true to false in /etc/wsl.conf (source)

resolve the issue apparently (while 1. is temporary and only persists until the next restart of WSL). The common cause seems to be the (indirect) install of mono-runtime package.

Personally disabling systemd is not an option given that I just spent a lot of time & effort getting SSH to auto-start in WSL…

Is anyone aware of the actual root cause? (Or was that already covered above?)

It should be caused by the conflict with systemd.

Please check the file /etc/wsl.conf and see if the systemd = true flag was added under [boot] settings as shown below. If so, please switch it to false.

Snipaste_2023-01-12_11-45-09

For more info, please refer to https://learn.microsoft.com/en-us/windows/wsl/wsl-config#per-distribution-configuration-options-with-wslconf

This also worked for me

restarting wsl with power shell > wsl --shutdown helped.

systemd-1 on /proc/sys/fs/binfmt_misc type autofs

WSL isn’t going to inject anything systemd related, anywhere. You probably have critically missing steps in the repro. To test that hypothesis, install a clean 20.04 (only because you’re on 18.04 not for the upgrade), see if notepad.exe works.

This started after a Visual Studio Code upgrade.