Skip to content

Commit

Permalink
Fix running Windows .exe files from a WSL/Ubuntu command prompt when …
Browse files Browse the repository at this point in the history
…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 microsoft/WSL#4567 (comment).

(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:
    microsoft/WSL#8843 (comment)   (Create /usr/lib/binfmt.d/WSLInterop.conf.)
    microsoft/WSL#8843 (comment)   (sudo systemctl mask systemd-binfmt.service)
  • Loading branch information
shaneharper committed Nov 2, 2023
1 parent 8b93c94 commit a759deb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a759deb

Please sign in to comment.