My Digital Garden

WSL stops running windows programmes

WSL stops running windows programmes

Occasionally WSL throws a wobbly and won't run a Windows programme, citing an "exec format error".

Most commonly when you fire up the ubiquitous code . to run CS Code in the current directory.

The cure is documented in this Github Issue:

  1. sudo vi /usr/lib/binfmt.d/WSLInterop.conf
  2. Insert these contents:
    :WSLInterop:M::MZ::/init:PF
    
  3. close terminal
  4. from windows shell wsl -t <DISTRO>
  5. restart WSL2

See also