Sunday, November 15, 2009

'Cannot allocate memory' Error When Ungzipping 03modlist.data.gz

If you've got the following error:

Going to read /root/.cpan/sources/modules/03modlist.data.gz
Could not pipe[/bin/gzip --decompress --stdout /root/.cpan/sources/modules/03modlist.data.gz |]: Cannot allocate memory at /usr/share/perl/5.8/CPAN.pm line 5728.

you are likely using VPS (Virtual Private Server) with little RAM. Fortunately, last versions of CPAN.pm handle this problem better, though CPAN.pm will likely go to swap anyway, so get prepared to wait. Unfortunately, you cannot use CPAN.pm to upgrade your CPAN.pm because of this error.

What you need to do is to install CPAN.pm manually. Go to http://search.cpan.org/dist/CPAN/ and download the latest stable version, e. g.

wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/CPAN-1.9402.tar.gz
tar -xzf CPAN-1.9402.tar.gz
cd CPAN-1.9402/
perl Makefile.PL
make
make test
sudo make install

Stop as many daemons as possible, particularly those requiring much memory, such as Apache and MySQL. Then proceed with

sudo perl -MCPAN -eshell

Enjoy!

No comments: