Is it currently possible to distribute pre-built binaries of Crystal applications?

I wonder if it is currently possisble to upload a pre-built Crystal binary to a Linux repository and a user would be able to install it with apt install myapp without requiring Crystal, like redis? My main concern is the ability to build static binaries for many platforms and OSes.

1 Like

The compiler itself is distributed as a pre-built binary in several package formats, so it should be very much possible.

Of course it’s possible, I’m doing that already. dpkg packages are built for a specific architecture (or all) and typically for a specific distribution, precisely to address the concerns you have. Static linking may seem like a good idea, but often isn’t. In short, you use a clean docker image of a target distribution on a target architecture with crystal and all the -dev packages installed, you build your dynamic binary there, you dpkg-deb -b your .deb and push it to the repo, done. Then you just apt install it on a target machine, no crystal needed there.

1 Like

Thanks for responses! BTW, @stronny, it would be great if your created an article describing the process :slight_smile:

What, another one? There is already like a million of them, this has nothing to do with crystal, it’s just general packaging skillset. I would be glad to help though, if you need assistance.

1 Like

That’s not true, by default crystal builds shared lib binaries, which then will have dependencies on a specific libs eg. openssl (which an exact version), zlib etc., so if you build in Ubuntu 16.04 it won’t work in Ubuntu 18.04 etc (becasue of mismaching openssl version). To create truly dependency less binaries you have to build with --static, but that’s currently only possible on Alpine Linux (musl). One drawback there is as of writing the latest Crystal version in Alpine is 0.27.0 (

I guess you could build on every possible linux dist/version you want to distribute to with the shared lib concept, with the benefit that the user can upgrade openssl, or libc version for bug fixes independently of the distributed binary.

What’s not true?

The typical usage of an apt repository is conceptualized around a distribution and is explicitely split by architectures. Some developers try to “optimize” that, more often than not to a detriment of their users.

If you intend to distibute dpkg packages via an apt repository you will have to “build on every possible linux dist/version you want to distribute to”, there is no way around it, and that is not a bug.