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:~$
brian d foy
  • 129,424
  • 31
  • 207
  • 592
Ricky
  • 2,850
  • 5
  • 28
  • 41
  • 2
    [`cpan install`](https://metacpan.org/pod/install) :-/ – melpomene Jul 29 '15 at 22:38
  • 6
    http://www.ivan.fomichev.name/2009/11/cannot-allocate-memory-error-when.html – choroba Jul 29 '15 at 22:44
  • 8
    @choroba Alternatively, [cpanm](https://metacpan.org/pod/App::cpanminus#INSTALLATION) may use less memory than cpan. – melpomene Jul 29 '15 at 22:47
  • 1
    @choroba I have a VPS with 256 MB memory and I don't run into this problem. Hmmmm ... – Sinan Ünür Jul 29 '15 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 Jul 30 '15 at 02:06
  • 1
    Thanks @choroba. I ended up installing cpanm and this worked great. I'm not sure why the original cpan did not. – Ricky Jul 30 '15 at 07:21
  • 1
    How often did you try? Could be your machine just had a hickup and it worked in cpanm because the lack of memory was over. – simbabque Jul 30 '15 at 08:08
  • @simbabque I actually rebooted my machine and tried again, to no avail. That's when I installed cpanm and it worked after. – Ricky Jul 30 '15 at 15:55
  • 1
    @Ricky can you please post your own answer and accept that, so the question doesn't show up as open any more and future visitors see the solution. Even if it's not really clear why it worked. Thank you. – simbabque Aug 03 '15 at 09:03

5 Answers5

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.

bytepusher
  • 1,568
  • 10
  • 19
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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
4

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.

Richard Wheeldon
  • 973
  • 10
  • 25
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

rogerdpack
  • 62,887
  • 36
  • 269
  • 388