1

I'm on Debian 12 (Bookworm). I have had Mono installed (from https://download.mono-project.com/repo/debian, to run Duplicati backup software) for years. I'm trying to get Wine working smoothly.

Wine works well enough when invoked directly: wine hello.exe does the right thing. But I can't run hello.exe directly from the command line.

I did sudo apt install wine-binfmt to get the Wine binary-format handlers installed. But still:

$ ./hello.exe
Cannot open assembly './hello.exe': File does not contain a valid CIL image.

I think that's because I've got two handlers registered for MS-DOS ("MZ" executables "4d5a"):

$ cat /proc/sys/fs/binfmt_misc/cli
enabled
interpreter /usr/lib/binfmt-support/run-detectors
flags:
offset 0
magic 4d5a
$ cat /proc/sys/fs/binfmt_misc/wine
enabled
interpreter /usr/lib/binfmt-support/run-detectors
flags:
offset 0
magic 4d5a

Oh, but they both point to run-detectors as the handler, which ... stores its config files in /usr/share/binfmts/ ... and I've got two overlapping handlers in there:

$ cat /usr/share/binfmts/cli
package mono-runtime
detector /usr/lib/cli/binfmt-detector-cli
interpreter /usr/bin/cli
magic MZ
$  cat /usr/share/binfmts/wine
package wine
interpreter /usr/bin/wine
magic MZ

The cli command is Mono (readlink -f /usr/bin/cli => /usr/bin/mono-sgen). I assume the Mono "binaries" that cli expects are .NET bytecode packaged to look like an MS-DOS binary? Is there some "detector" I can install that disambiguates a Mono binary from a "regular" MS-DOS binary and sends one kind to Mono and one kind to Wine?

4
  • /usr/lib/cli/binfmt-detector-cli is supposed to disambiguate these kinds of binaries (its the "detector" filter in the "cli" entry). Its not working in my setup....
    – P.T.
    Oct 10 at 22:16
  • It seems like PE binaries built by Zig look like "CLI" binaries to the detector. So maybe a different problem....
    – P.T.
    Oct 10 at 22:46
  • The question is a better fit for Unix & Linux anyway, voting to migrate it. Oct 11 at 5:36

1 Answer 1

1

The current /usr/lib/cli/binfmt-detector-cli has a bug and classifies most PE32+ binaries as "CLR" (i.e., for Mono). Before May 2022 the classifier has a bug where all PE32+ binaries were classified as native. See https://github.com/mono/linux-packaging-mono/pull/38.

Fixing the classifier to correctly classify PE32+ binaries as CLR or not fixes my problem (the rest of the Wine/Mono stack and the wine-binfmt all work as intended).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .