Skip to content

WSL2 (Preview) cannot run .exe files: exec format error: wsl.exe #8952

@blami

Description

@blami

Version

Microsoft Windows [Version 10.0.22621.521]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.62.1-microsoft-standard-WSL2

Distro Version

Ubuntu 22.04

Other Software

systemd 249.11-0ubuntu3.3

WSL version: 0.68.2.0
Kernel version: 5.15.62.1
WSLg version: 1.0.44
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.521

Repro Steps

  • [optional] disable wslg
  • [optional] enable systemd support
  • make sure interop is not disabled
  • attempt to run wsl.exe --version from any shell inside WSL2
  • ls /proc/sys/fs/binfmt_misc/ for presence of WSLInterop

Expected Behavior

  • wsl.exe will exe will execute and output version on terminal
  • /proc/sys/fs/binfmt_misc/ will contain custom binary format for WSL interop

Actual Behavior

After upgrade to preview version of WSL2 (ver. 0.68.2.0 from Github on non-Insider build) it was possible to run Windows binaries from within WSL2 by simply having them in PATH and typing binary.exe with systemd enabled and disabled.

After Windows build 22H2 upgrade this is not longer possible. Shell sees binaries in PATH but its not possible to run them, error message being exec format error: wsl.exe. After further inspection I found WSL interop is not registered with binfmt_misc:

~ $ ls /proc/sys/fs/binfmt_misc/
llvm-15-runtime.binfmt  qemu-arm     qemu-mips64el  qemu-riscv64  register
qemu-aarch64            qemu-mips64  qemu-ppc64le   qemu-s390x    status

After upgrade I noticed Hypervisor Platform was disabled although I am sure I had it enabled before. I reenabled it but it didn't solve the issue.

Diagnostic Logs

~ $ cat /etc/wsl.conf
[boot]
systemd = true

[automount]
enabled = true
mountFsTab = true
root = /mnt/
options = "metadata,umask=2,fmask=1,case=off"

[network]
generateHosts = true
generateResolvConf = true

[interop]
enabled = true
~ $ cat /mnt/c/Users/blami/.wslconfig
[wsl2]
guiApplications = false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions