Cargo build appimage

I've been trying to generate an AppImage for a Rust program, on Linux. Notes:

  • There's a Cargo tool for this: cargo appimage. It creates a single executable file which mounts a file system containing everything in the package.

  • It needs "appimagetool" pre-installed somewhere on the current $PATH. That's not packaged with the Cargo tool, and it's not a standard Ubuntu application. So it has to be downloaded from here. You get to pick a version: "pre-release", from 2023, or "13", from 2020. When you download it, you get an AppImage file, named something like " appimagetool-x86_64.AppImage ".

  • cargo appimage wants "appimagetool" to be named "appimagetool", so you have to rename or link the above file.

  • cargo appimage has to be called with the current directory set to the root directory for the executable you want to package, not the workspace root if you have a workspace. Failure to do this gets useful error messages: "os error 2: File not found".

  • You get to specify a list of directories to be copied into the packaged distribution. Those are specified relative to the root directory for the executable you want to package. They go into the package relative to its root, which may or may not be what you want. There's no option to specify a different source and destination. So you have to lay out your directories accordingly.

  • The executable to be run is placed in "usr/bin/bin" in the packaged file system. The executable file is actually called bin, and that's probably what you're going to see at the top of its window. The executable file needs to know to look for its assets relative to "../.." from the location of the executable.

  • When it builds the AppImage file, it places it in the root directory of the project that generates the executable. Not in the target subtree. It knows to look for the executable in the target subtree, so it understands Cargo file layout. It just isn't consistent with it.

It seems to be possible to get this to work, but it wants certain files in specific directories, ones not entirely consistent with usual Cargo layout. This is a headache if you already have an existing project. If it just put the executable in the root directory of its file system, had enough smarts to find "appimagetool" by itself, and reported errors better, it would be more usable.

Is AppImage used much?

Exact usage statistics of AppImage are hard to come by, as AppImage doesn't have a central repository like a lot of other package management systems. Regardless, it is fair to say that AppImage is one of the lesser used Linux package formats.

The maintainer of cargo-appimage seems responsive to issues, so you could bring your problems up with them. You could also try making a PR to make the tool do what you want, I'm sure StratusFearMe21 would appreciate it.


I get that.

With all the work that went into successfully making Rust compile cross-platform, it's surprising how badly supported the last step, packaging for delivery, is.

Yeah, packaging support for Rust is not great. I find packaging for Arch Linux and the AUR to be pretty good though.

Looks like AppImages can be made without the appimage binary with xbuild. I haven't tried it yet though.

Something to look into.

For now, I fell back to the traditional solution - a shell script that creates a .tar.gz file. A bit retro.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.