4

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Installing R packages takes more memory than raspberry has. To make it work you need to create a swap space temporarily (so it won't kill your disk in the long run). See http://raspberrypi.stackexchange.com/questions/70/how-to-set-up-swap-space – OganM Dec 14 '16 at 03:01
  • 1
    I managed to find a solution after finding this question: http://stackoverflow.com/questions/7765429/unable-to-install-r-package-in-ubuntu-11-04 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 Dec 14 '16 at 15:11
  • 2
    Oh dear, this question has gotten into a bit of a state! Note that on Stack Overflow, we prefer one question per post, without a history of what your previous question was, for ease of reading for current and future readers. I suggest that you provide an answer to the original question below (as an answer post) and then ask a new question, hyperlinking to this one if that is helpful for the new case. I have rolled back, but you can copy pieces of the new question [from the revision history](https://stackoverflow.com/posts/41132931/revisions). Thanks! – halfer Dec 14 '16 at 19:10

1 Answers1

1

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

Armali
  • 18,255
  • 14
  • 57
  • 171