Using stack on Raspberry Pi

Hello. I am trying to compile a Haskell project with a web server to be hosted on a Raspberry Pi. It is running Ubuntu Server 20.10 (Linux 5.8.0, aarch64 architecture). I have successfully installed the haskell-platform and haskell-stack packages. However, when running stack build after cloning the repository of my project, I get the following output:

Unable to find installation URLs for OS key: linux-aarch64-tinfo6

Does it mean stack does not work on my architecture for the moment? I have tried to find some information about this kind of support on the Internet, but I constantly fall back to articles on cross-compilation, which is not what I am trying to do right now. I would like to compile on aarch64 for aarch64. Anyway I hope cross-compilation is not my only solution because it looks like a mess.

Thanks in advance for your help !

I believe you are looking for the libtinfo-dev package?

On ubuntu, that would be like:

$ sudo apt-get install libtinfo-dev 

I would try installing that with apt.

Also, I would install stack directly from the project with their script:

$ curl -sSL https://get.haskellstack.org/ | sh

Goodluck, and please post updates! I have always wanted to do this but haven’t put in the time.

IDK if this is still relevant, but https://svejcar.dev/posts/2019/09/23/haskell-on-raspberry-pi-4/ might be useful.

1 Like

libtinfo-dev is already installed. Also, the stack installation phase in your link did not work.

Detected Linux distribution: ubuntu

Sorry, currently only 64-bit (x86_64) Linux binary is available.

That is actually why I found another way to install stack, through the Ubuntu package.

I really wonder what is simpler between trying to cross-compile my project on my Mac for this specific linux-aarch64-tinfo6 target, and getting stack to work directly from the Raspberry Pi.

1 Like

Yea, that’s usually the dilemma with cross-compiling and embedded systems.

WRT the stack install, you could also try building a stack binary for RPi :slight_smile:
Thanks for the updates, it’s nice to see more recent notes on what works and what doesn’t.

1 Like

i just hit the same error. I am on a raspi4 and installed a clean debian (from https://raspi.debian.net/tested-images/) - nice: dual monitors, fast (with ssd). but no usable installation of stack (which i am used). I can compile and run a trivial program with cabal (and may switch to use cabal). What did you try?

There are some people on the Internet talking about how haskell.nix saved their children from certain death or cured their worst diseases. Jokes aside, some people in corporate contexts seem to have chosen this solution, so it might be solid, but I took a look into the configuration files and it seems complicated to setup. I know nothing about Nix and do not want to invest too much time into it before being sure it is the only solution left.

I think I was able to get a cabal working, but I fear that my error does not disappear, because it looks like a missing target triple in GHC. Anyway, I might just use the .cabal file usually generated by stack thanks to the package.yaml file in the project structure and tell you what happened.

1 Like

seems the problem with stack has a trivial solution: install libtinfo-5. I installed with apt and now stack does upgrade. I will report later.

I did the same and now I get the following output for stack build:

No setup information found for ghc-8.8.4 on your platform.
This probably means a GHC bindist has not yet been added for OS key 'linux-aarch64', 'linux-aarch64-ncurses6', 'linux-aarch64-tinfo6'.
Supported versions: ghc-8.2.1, ghc-8.2.2, ghc-8.4.1, ghc-8.4.2, ghc-8.6.2, ghc-8.6.5, ghc-8.8.1, ghc-8.8.2, ghc-8.8.3, ghc-8.10.1, ghc-8.10.2, ghc-8.10.3, ghc-8.10.4, ghc-9.0.1

This is a better error message. I guess I just have to choose another version of the compiler, which is not limiting at all for me.

I just want to say that, beyond our compilation issues for ARM 64-bits, I find it disturbing and not user-friendly to have a working haskell-stack Ubuntu package, yet a failing official installation script through curl.

But I’ll stop being negative on stack for a while, because the ecosystem is already very nice for desktop projects and I do not want to be regarded as critical. I have only heard about cabal's dependency hell and thankfully stack allowed me to build several projects without having to actually dive into it.

It looks like stack wants me to add all the recursive dependencies of the packages I need to compile my program to the stack.yaml file in the extra-deps section. Every line I add makes stack asks for a dozen other.

On an other aspect, it looks like stack is taking a long time to run, and in the link given in the first answer on this thread, the guy says 1 GB is not enough to compile a project with stack. I expect it to crash soon. However, it looks liks stack works with the libtinfo-5 package added, so I think a good way to get my program to compile would be to run an ARM 64 Linux image on QEMU on a machine with more RAM (my mac has 16 GB), install stack like if I were on the Pi, then compile my project and extract the executable to the host, so that I can scp it back to the Pi and have a working executable.

If this expected stack crash behaviour happens, I think I will try this option and tell you about it.

1 Like

That’s sounds like a gap worth talking more about, or at least opening a ticket in stack’s github so more people can pool what they know about the situation and a solution may come out.

:+1: it’s worth a shot (may still produce a bad executable, but certainly faster than iterating on the RPi)!

Hello. A quick update. I have tried the QEMU option in a Docker container (lukechilds/dockerpi) but basically it’s a Pi 1 and extracting / installing GHC just failed for an unknown reason (probably performance). The next and last option I will try is compiling a specific GHC targeting ARM64.

If this fails I will probably just give up and build my back-end in Scala, which would be very disappointing.

EDIT: to be honest I would probably try OCaml before Scala. It is my main language and the one I know best :grinning_face_with_smiling_eyes:

Next and last update. As my back-end was rather simple (a few files), I rewrote it in another language that is more compatible with such a platform. It is de facto less elegant and a lot more verbose, but I think it was worth the change, considering the issues I have encountered across the last few days.

I will not investigate further in Haskell for this project, but know that this does not discourage me for future projects. I remain a functional programmer at heart, and I have yet to master advanced concepts like monad transformers, which I am, at this point, still too afraid to use in my projects. However, I will keep in mind this bias that Haskell is made neither for embedded systems nor mobile platforms, and is more adapted to desktop projects or web servers.

Please feel free to add comments below about your experience about Haskell and ARM targets. This thread might, hopefully, turn into a good documentation for newcomers as to how to configure a project cross-compiling for an ARM target, and change my mind, once the support gets way better in the future.

Thanks to everyone for your useful and friendly replies.

Best regards.

2 Likes

I had the same problem when trying to use stack on a Pi 3. Stack stopped providing native ARM binaries at some point, and the last available version on Ubuntu repositories is too old to be used. As others have mentioned, I find the combination of nix and cabal-install to work quite well in this case. It does involve some investment and initial boilerplate, but at a reasonable level in my opinion. In any case, ARM support is crucial these days, and should be a priority to help with the adoption of Haskell.

3 Likes

TL;DR: Here are the commands in a concise form:

apt update && apt upgrade -y
apt install build-essential libnuma1 libnuma-dev libtinfo-dev libtinfo5 libtinfo6 libc6-dev
apt install llvm* # all the packages (runtimes, tools, linkers avaiable for llvm 9 through 12)
apt install clang ninja-build # I have doubts here but installed these two packages anyway
apt install haskell-stack
stack update # just updating the packages took half an hour or more using an sd card
stack upgrade # it took a couple (close to 3) hours (with a ssd but I believe this process is mostly cpu bound so be prepared for a solid 5 hours with a sd card to complete)

Output for stack --version afterwards

I hope this helps.

Editted:

  • Rebooted the pi and ensured that $PATH pointed to /home/$username/.local/bin
  • stack --version output log
  • Uptime after concluding stack upgrade was 4 hours. (overclocked pi at 2.0GHz)
  • Ram usage went a little over 4gb during Progress 143/168: aeson, mono-traversable
  • Trashed initial post
3 Likes