Installing dependencies w/ cabal on server floods RAM

Hi, I simply try to install

cabal install telegram-api http-client

my SSH on the server becomes unresponsive when it tries to compile some things. I think it’s because I only have 1gb of RAM and it gets flooded with the compilation.

Is there anything I can do?

Hello Lucas, maybe try

--jobs=1 --ghc-options='+RTS -M512M'

and tell us if it helps. I use it when I have to compile mammoth packages like pandoc.

2 Likes

I got

ghc: Heap exhausted;
ghc: Current maximum heap size is 536870912 bytes (512 MB).
ghc: Use `+RTS -M<size>' to increase it.

One further trick is to temporarily enable a swap file in your machine, as described here. This should be used in combination with –jobs=1.

1 Like

You can also try installing the packages telegram-api and http-client separately or even install dependencies of those packages separately first. For example, servant, which is a dependency of telegram-api, is already a large package and could be installed separately before installing telegram-api.

2 Likes

This may sound a bit radical but you could try to employ Nix. It will just download all binary packages needed. In a sense, you would trade RAM for disk space as Nix will fetch a lot of stuff along the way.

2 Likes

Sounds like a GHC problem, unfortunately. I have a 4GB RAM arm box and it runs out of RAM routinely :\

1 Like