From a759deb7ab792f038e8735c185a55e97b2d2e572 Mon Sep 17 00:00:00 2001 From: Shane Harper Date: Fri, 3 Nov 2023 10:10:48 +1100 Subject: [PATCH] Fix running Windows .exe files from a WSL/Ubuntu command prompt when mono-runtime is installed and systemd is enabled. Trying to run "explorer.exe" from a WSL/Ubuntu command prompt, for example, would result in the following error: run-detectors: unable to find an interpreter for /mnt/c/Windows/explorer.exe The fix was taken from https://github.com/microsoft/WSL/issues/4567#issuecomment-680034755. (I confirmed that the mono-runtime package added the cli entry that caused the problem by running "update-binfmts --display".) I'd tried the following but they didn't work for me: https://github.com/microsoft/WSL/issues/8843#issuecomment-1337127239 (Create /usr/lib/binfmt.d/WSLInterop.conf.) https://github.com/microsoft/WSL/issues/8843#issuecomment-1624028222 (sudo systemctl mask systemd-binfmt.service) --- install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install b/install index a0ef015..c68ce44 100755 --- a/install +++ b/install @@ -59,3 +59,7 @@ fi echo About to install python3-dev and mono-complete. sudo apt install --assume-yes python3-dev mono-complete # Install packages needed by YouCompleteMe Vim plugin. xxx It'd be nice to only ask for a password (run sudo) if a required packages isn't installed - See https://stackoverflow.com/a/10439058. xxx Move this to vimrc to be near the code that installs YouCompleteMe. + +if [[ $(uname -r | grep WSL) ]]; then + sudo update-binfmts --disable cli # Without this (and with mono-runtime - part of mono-complete - installed and with systemd enabled) trying to run a Windows exe from WSL/Ubuntu doesn't work, e.g. "run-detectors: unable to find an interpreter for /mnt/c/Windows/system32/cmd.exe" is output when trying to run cmd.exe (Ubuntu 22.04.3, mono-runtime 6.8.0.105+dfsg-3.2). +fi