10

I'm getting the following error 'Cannot allocate memory' when attempting to install the Moose package for Perl.

Can anyone advise what is wrong here?

ricky@rickyp:~$ sudo cpan install Moose
Reading '/home/ricky/.cpan/Metadata'
  Database was generated on Wed, 29 Jul 2015 21:41:02 GMT
Running install for module 'Moose'
Running make for E/ET/ETHER/Moose-2.1405.tar.gz
Checksum for /home/ricky/.cpan/sources/authors/id/E/ET/ETHER/Moose-2.1405.tar.gz ok
Uncompressed /home/ricky/.cpan/sources/authors/id/E/ET/ETHER/Moose-2.1405.tar.gz successfully
Using Tar:/bin/tar xf "Moose-2.1405.tar":
Couldn't untar Moose-2.1405.tar: 'Cannot allocate memory'
Package seems to come without Makefile.PL.
  (The test -f "/home/ricky/.cpan/build/ETHER-Al52av/Makefile.PL" returned false.)
  Writing one on our own (setting NAME to Moose)
  Had problems unarchiving. Please build manually
Running make test
  Make had some problems, won't test
Running make install
  Make had some problems, won't install
ricky@rickyp:~$
9
  • 2
    cpan install :-/
    – melpomene
    Commented Jul 29, 2015 at 22:38
  • 6
    ivan.fomichev.name/2009/11/…
    – choroba
    Commented Jul 29, 2015 at 22:44
  • 8
    @choroba Alternatively, cpanm may use less memory than cpan.
    – melpomene
    Commented Jul 29, 2015 at 22:47
  • 1
    @choroba I have a VPS with 256 MB memory and I don't run into this problem. Hmmmm ... Commented Jul 29, 2015 at 22:48
  • 2
    How much memory do you have? How much is being used by other programs? Web browsers can be a big memory hog... Try closing everything else and retrying.
    – xxfelixxx
    Commented Jul 30, 2015 at 2:06

5 Answers 5

9

Answering so it is no longer unanswered. The OP solved his problem by using cpanm.

If you have problems installing modules, cpanp may be another alternative to cpan you can look at.

2
  • cpanp is likely to have the same problem. Commented Aug 30, 2015 at 15:30
  • "may be another alternative" should give you a hint to try cpanm first.
    – bytepusher
    Commented Aug 30, 2015 at 17:54
5

If you're using cpan(1) on a system with limited memory, such as a bottom-level hosting account, it's likely that CPAN.pm can't fit the module index in memory or takes up most of the memory you do have. CPAN the repository is huge now, so what used to be a small index file is pretty large. Indeed, it's the most annoying part of the process for me since it takes a noticeably long time to download and load.

cpanminus (cpanm) does things different by using the MetaCPAN API to look up the info it needs. It has a really small memory footprint.

Or, you could be running something else at the same time that's taking up memory.

3

I had the same problem recently on a box which had no swap partition. Adding a small swapfile (dd /dev/zero to new file, mkswap on the file, swapon) fixed the problem even though cpan doesn't appear to be using any significant amount of memory or swap.

0

I too have faced the same. If you are using Virtual Machine, increase base memory[RAM]. CPAN install should work.

0

Sure enough, this means "hard failure you need more memory available". I was able to get it to work by turning off my chrome browser LOL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.