Closed abl closed 4 years ago
Try exploring the contents of ls /proc/sys/fs/binfmt_misc/
and report back. Microsoft might have installed some MZ executable shell script hook even though WSL can't run Windows binaries.
As far as playing sound is concerned, all you need to do is apt install either ffmpeg or sox. No system interface consensus exists for sound so we do it by piping raw audio into those commands.
Yeah, binfmt_misc
is clearly part of the problem; here's the one registered definition.
❯ \cat /proc/sys/fs/binfmt_misc/WSLInterop
enabled
interpreter /tools/init
flags: F
offset 0
magic 4d5a
I had a chance to read your αpε writeup and noticed the zsh issue; sh o/tool/viz/printvideo.com cats.mpg
worked with binfmt_misc
on!
...then I toggled it off, and it didn't:
❯ sh o/tool/viz/printvideo.com cats.mpg
o/tool/viz/printvideo.com: 1: ELF: not found
o/tool/viz/printvideo.com: 2: @8�@�����H�1ҽ��8��p1�����X�^��k����u����ގ�1�1���@���1���U��0���1�1���@t#�.�����0�1ɉ��]�ƃ�: not found
o/tool/viz/printvideo.com: 3: Syntax error: ")" unexpected
...then I toggled it back on, and it still didn't, same output.
However, o/tool/viz/printvideo.com cats.mpg
now works directly in ZSH regardless of binfmt_misc
status. sh -c o/tool/viz/printvideo.com cats.mpg
works, bash works, running the command directly in sh/bash works.
Could you try running the following command and let me know if it fixes the issue?
sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"
Registered that format:
───────┬──────────────────────────────────────────────────
│ File: /proc/sys/fs/binfmt_misc/APE
───────┼──────────────────────────────────────────────────
1 │ enabled
2 │ interpreter /bin/sh
3 │ flags:
4 │ offset 0
5 │ magic 4d5a71467044
───────┴──────────────────────────────────────────────────
No effect with binfmt_misc
enabled/disabled.
FWIW /bin/sh
is symlinked to dash
?
I'm having difficulties figuring out how to get binfmt_misc to work. I would recommend disabling it entirely if possible. Hopefully someone else can come along who understands it and show us how to configure it for the people who do.
Another user is reporting in #2 that the one-liner workaround I posted a few comments earlier should be OK. I'm going to close out this issue. Thanks for the report!
Marking as duplicate of #2 for posterity. Thanks again for using Cosmopolitan!
Really interesting project!
Started looking at the example under WSL 2 (Ubuntu 20.04.1 LTS) since I had that handy.
Running with
-j8
fails with errnos 5 and 32.WSL 2 does have a
binfmt_misc
set up for windows interop; disabling it withsudo sh -c 'echo 0 > /proc/sys/fs/binfmt_misc/status'
allowsmake -j8
to succeed - deleted my clone and pulled a fresh one after disabling.Re-enabling
binfmt_misc
afterwards gets a little farther:Attempting to run the executable from Windows directly produces the same (lack of) output;
ffplay
is installed on the WSL side, fwiw.If anything jumps out as far as what I should try/test please let me know - I've just started to trace and debug now.