Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`cabal update` failed due to `out of memory`

Here is what cabal update outputs:

Downloading the latest package list from hackage.haskell.org
cabal: out of memory (requested 2097152 bytes)

The reason may be shortage of memory. What about tail 00-index.cache?

pkg: charade 0.1 b# 46384
pkg: charset 0.0 b# 46390
pkg: charset 0.1 b# 46393
pkg: charset 0.2.0 b# 46396
pkg: charset 0.2.1 b# 46399
pkg: charset 0.2.2 b# 46402
pkg: charset 0.2.3 b# 46405
pkg: charset 0.3 b# 46408
pkg: charset 0.3.0.1 b# 46412

I can have 00-index.tar.gz downloaded easily and have 00-index.tar untared. However, because of out of memory, I cannot generate the cache file! Can cabal generate 00-index.cache locally in an cheap way?

cabal --version

cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
like image 266
eccstartup Avatar asked Dec 25 '13 04:12

eccstartup


2 Answers

I ran into a similar problem running a micro instance on AWS (not running cabal update, but compiling my own program). I followed the suggestions in this link to create a swap space and it did the trick.

From the link:

> dd if=/dev/zero of=/tmp/swap bs=1M count=1024
> mkswap /tmp/swap
> swapon /tmp/swap

The dd command creates a swap file with the name “swap” under the /tmp directory with a size of 1024MB (1GB).

Make this file as a swap file using the mkswap command.

Enable the newly created swapfile using the swapon command.

This link has more information about swap spaces.

like image 165
stormont Avatar answered Oct 19 '22 04:10

stormont


You can just put 00-index.cache in the appropriate place, and cabal-install will use it just fine. To find out where to put it, look at the value of remote-repo-cache and remote-repo in ~/.cabal/config; the cache should go in a directory named after the remote repo's nick inside the remote-repo-cache directory. For example, here's a snippet of my config:

remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /home/dmwit/.cabal/packages

and my cache is in /home/dmwit/.cabal/packages/hackage.haskell.org/00-index.cache.

like image 25
Daniel Wagner Avatar answered Oct 19 '22 03:10

Daniel Wagner