大网数据广告活动
服务器运维问答

Make Wine and Mono command-line invocations play well together on Debian?

· 52CE 我爱测

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 invoke…

问题原文

原帖链接 · P.T. · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · P.T. · CC BY-SA 4.0

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).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-10-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。