When I try to add it to sources as per debian install instructions I get this error. I'm guessing this means that there are no arm packages for it.
Failed to fetch https://dist.crystal-lang.org/apt/dists/crystal/InRelease Unable to find expected entry 'main/binary-armhf/Packages' in Release file (Wrong sources.list entry or malformed file)
I'm guessing I probably need to install it from source. How would I go about doing that with an arm cpu? When I check it out and run make
I get the error:
You need to have a crystal executable in your path! Makefile:113: recipe for target '.build/crystal' failed make: *** [.build/crystal] Error 1
Any suggestions would be greatly appreciated.
EDIT: There's now a semi-official repository for crystal on raspbian, check it out here: http://public.portalier.com/raspbian
Crystal doesn't build Debian packages for ARM, and you're correct in that you'll need to build from source.
However, the Crystal compiler is written in Crystal. This presents the obvious problem of how to get a compiler to build the compiler. The answer is cross-compilation: building an arm binary on a x86 desktop computer and copying it across.
Here's a quick step-by-step based on my memory of last time I cross-compiled:
make deps
../bin/crystal build src/compiler/crystal.cr --cross-compile --target arm-unknown-linux-gnueabihf --release -s -D without_openssl -D without_zlib
This command will create a crystal.o
file in your current directory, and also output a linker command (cc crystal.o -o crystal ...
).crystal.o
to the raspberry pi, and run the linker command. Be sure to edit the absolute path to llvm_ext.o
so that it points to the Crystal checkout on your Raspberry Pi, not the checkout on your desktop. Also make sure that all references to llvm-config
in the command are for the correct LLVM version. For example, changing /usr/local/bin/llvm-config
to llvm-config-3.9
on Raspbian../crystal -v
) and make sure it works.CRYSTAL_PATH
environment variable is set to lib:/path/to/crystal/source/checkout/src
so that the compiler can find the standard library when compiling applications. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With