"Cannot allocate memory" and "non-zero exit status" - Can't install R packages on Raspberry Pi

1.8k views Asked by At

I'm having this problem while trying to install any package in my Raspberry Pi.

Some general info about the system and software:

Raspberry Pi 3
Raspbian Jessie with Pixel (Novermber 2016, latest version)
R 3.1.1

When I try install.packages("XML"), it asks me to choose a mirror, then after I choose and it download, the result is:

The dowloaded source packages are in  
'/tmp/RtmpBOxeKj/downloaded_packages'

Warning messages:
1: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile) : system call failed: Cannot allocate memory
2: In install.packages("XML") : installation of package 'XML' had non-zero exit status

This happens with any package I try to install (sometimes only the second error and sometimes both).

After booting Raspbian I have 610MB of free RAM and after opening the R console I have 582MB of free RAM, then goes down to 282MB when I try installing the package. Shouldn't that be enough?

Any idea?

1

There are 1 answers

0
Armali On

I managed to find a solution after finding this question: stackoverflow.com/questions/7765429/…

sudo apt-get install libxml2-dev

After this I was able to install the XML package. By typing apt-cache search r-cran-* it will show a list of many other R packages. I just installed all of them so that I dont need to do it again in case this problem happens again in the future, but one could only install what is needed, of course. – Bruno Caram Muller