`cabal update` failed due to `out of memory`
Asked Answered
G

3

13

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
Geraldina answered 25/12, 2013 at 4:56 Comment(7)
Am I reading that right? You don't have two megabytes of memory? ...and you're planning to build Haskell tools from source?Devil
No! I did it successfully last time! It is located on VPS. @DanielWagnerGeraldina
@DanielWagner My assumption is that that's the size of the allocation that failed, not the total size of allocations.Kobold
Can you explain it? @DanielWagnerGeraldina
eccstartup: did you solve this eventually? Having the same issueManufacturer
@Manufacturer Not sure. I suspect the 512M memory was not enough.Geraldina
In case you're still struggling with the issue, @franka, I ran stormont's solution with swap spaces, and it worked!Chafee
I
19

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.

Intemerate answered 29/1, 2015 at 5:40 Comment(3)
I just blindly ran these commands on my DigitalOcean droplet running Ubuntu 14 (because its newly spun up and I have nothing to lose). It worked! Thanks stormont!Chafee
Why does this happen in the first place? 2097152 bytes ~ 2MB. Even on a t1 micro instance(the case where I'm running into this error) you have .613GiB ~ 600 MB of memory. If i run top before cabal update, it shows i have over half of this memory available so it seems like it should easily be able to handle this. Unless cabal itself is taking up most of that memory and the reported bytes requested are what's required for the install?Vertumnus
I think the requested bytes statement is just saying how much more cabal is looking for, not how much it has consumed. So, the OP was near his memory allocation limit when the extra 2MB's were requested.Intemerate
D
1

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.

Devil answered 25/12, 2013 at 6:13 Comment(0)
D
-4

Try adding more memory to the machine on which you're running cabal update.

I once was trying to install GHC and compile some Haskell on a DigitalOcean bottom-tier server, and compilation always failed due to the lack of available RAM. Trying again on a more well-equipped server fixed the issue.

Dodds answered 14/1, 2015 at 17:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.