All I'm trying to do is getting a manually installed mono (to /opt/mono-2.10) to run CLI executables without having to specify the interpreter explicitly. Wine is not installed.
Ubuntu 10.10. No mono package is currently installed (
dpkg -l | grep mono gives nothing), but they were in the past before I realized that I need a much newer one, so that's probably the source of this mess.
Running a CLI executable gives me this:
Can't exec "/usr/lib/cli/binfmt-detector-cli": No such file or directory at /usr/share/binfmt-support/run-detectors line 92.
That is correct,
/usr/lib/cli/binfmt-detector-cli does not exist and I don't know where it should have come from.
So I googled a bit and found some information about the binfmt_misc module. Indeed, it is loaded and I have a
/proc/sys/fs/binfmt_misc/cli which contains this:
enabled interpreter /usr/share/binfmt-support/run-detectors flags: offset 0 magic 4d5a
run-detectors script is Perl, but apparently doesn't work (this is probably Debian #575776):
user@host:/$ /usr/share/binfmt-support/run-detectors Use of uninitialized value in open at /usr/share/binfmt-support/run-detectors line 56. Use of uninitialized value $ARGV in concatenation (.) or string at /usr/share/binfmt-support/run-detectors line 56. run-detectors: unable to open : No such file or directory
But anyway, I don't have Wine, so I don't need all that binfmt-detector-cli stuff in the first place. I just want those binaries to be hard linked with the Mono interpreter. I found this answer on SU and this blog entry, which discuss how to change these rules. Unfortunately, trying that, I always get a 'permission denied':
user@host:/$ sudo echo .:CLR:M::MZ::/opt/mono-2.10/bin/mono:. > /proc/sys/fs/binfmt_misc/register bash: /proc/sys/fs/binfmt_misc/register: Permission denied user@host:/$ sudo echo -1 > /proc/sys/fs/binfmt_misc/cli bash: /proc/sys/fs/binfmt_misc/cli: Permission denied
/usr/share/binfmts/cli and changed it to
package mono-runtime interpreter /opt/mono-2.10/bin/mono magic MZ
but that seems to have no effect. Then there is
/var/lib/binfmts/cli, which I changed to
mono-runtime magic 0 MZ /opt/mono-2.10/bin/mono
but that also has no effect. I also found the script
update-binfmts but I can't get it to work. I don't even manage to remove an existing configuration. The following attempt for example leaves me with a rather cryptic error message:
user@host:/$ sudo update-binfmts --remove cli /opt/mono-2.10/bin/mono update-binfmts: warning: current package is <local>, but binary format already installed by mono-runtime ; not removing.
I have no idea whether my arguments were valid (the help page mentions
<path> but doesn't say the path to what it wants... or why), whether the second line is supposed to be an error message and whether it changed anything in the first place.
How do I make any executable that starts with the magic string 'MZ' to be run with
Update 1: The outputs to the commands Colin suggested:
user@host:/$ sudo update-binfmts --package mono-runtime --remove cli /opt/mono-2.10/bin/mono update-binfmts: warning: current package is mono-runtime, but binary format already installed by mono-runtime ; not removing. user@host:/$ dpkg -S /usr/share/binfmts/cli dpkg: /usr/share/binfmts/cli not found. user@host:/$ sudo rm /usr/share/binfmts/cli* user@host:/$ sudo update-binfmts --install cli /opt/mono-2.10/bin/mono --magic MZ update-binfmts: warning: current package is <local>, but binary format already installed by mono-runtime update-binfmts: exiting due to previous errors