Prevent Wine from launching Mozilla llamafile

Good morning!

I am having an issue where Wine, the Windows emulator, insists on taking care of launching Mozilla’s llamafile ( GitHub - Mozilla-Ocho/llamafile: Distribute and run LLMs with a single file. ) on my Fedora 40.

It looks like the llamafile is a multiplatform binary, and somehow Wine is taking precedence.

On my other Fedora PC I successfully ran the binary natively by uninstalling Wine. But I’d prefer not to.

How to reproduce:
Go to GitHub - Mozilla-Ocho/llamafile: Distribute and run LLMs with a single file. and follow the Quickstart steps, which are to download the binary, and chmod it to +x before launching it.

So my question is; Is there a way to stop Wine from launching when I run the llavafile?

Added llm, wine

tee /tmp/llamafile.xml << EOF > /dev/null
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-llamafile">
<comment>Llama executable</comment>
<generic-icon name="help-faq"/>
<sub-class-of type="application/x-executable"/>
<glob pattern="*.llamafile"/>
</mime-type>
</mime-info>
EOF
xdg-mime install --novendor /tmp/llamafile.xml

Thank you for the reply, @vgaetera . It seems like your response suggests that I install a mime type for the .llamafile extenstioned files. I ran the command, but I see it is still being started by wine. I am running Gnome, if that matters.

Be sure to run the above commands without sudo.
You may need to re-login to apply the changes.
If the issue persists, check the output:

xdg-mime query filetype /path/to/llamafile

Hey again.

Output from the xdg-mime command:

$ xdg-mime query filetype llava-v1.5-7b-q4.llamafile 
application/x-llamafile

Still being launched using wine… Strange! I launch the application from the terminal so:

$ ./llava-v1.5-7b-q4.llamafile 
002c:fixme:winediag:loader_init wine-staging 9.15 is a testing version containing experimental patches.
002c:fixme:winediag:loader_init Please mention your exact version when filing bug reports on winehq.org.
...

As you can see, the two first lines being outputed is from wine.

Not an exact fix, but how do you execute the llamafile? Does it run like a script or binary through something else (like java -jar thing.jar)?

Like thing.exe runs through wine Linux binary, so it sounds like a llamafile could be interpreted by/run through something explicit like llamafilerunner llamafile? I’d execute it like that and avoid the automatic wine running of it.

This is actually a known and documented issue:

Aha. Thank you very much!
The solution that solved it for me was:

sudo wget -O /usr/bin/ape https://cosmo.zip/pub/cosmos/bin/ape-$(uname -m).elf
sudo chmod +x /usr/bin/ape
sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
sudo sh -c "echo ':APE-jart:M::jartsr::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"

as stated in How to tell llamafile to *not* use system wine on a Linux box with wine installed · Issue #22 · Mozilla-Ocho/llamafile · GitHub

1 Like