0

I keep getting a similar error when trying to install xml2 and readr packages on Rstudio server runnning on an EC2 instance as this posted thread question:

Unable to install XML package in R on CentOS

I was successful with installing the xml2 package from the terminal with the following command:

sudo yum install libxml2-devel

and then installing & loading the package on the Rstudio server.

However the readr package I have had no luck. It keeps saying that it was downloaded in a termporary file. Also the following command did not work in the terminal

sudo yum install libreadr-devel

How do I install the readr package? It seems like somepackages can be installed straight from the Rstudio server and other from the terminal.

This is the error I get when trying to install the `readr package.

install.packages("readr")
Installing package into ‘/home/jessica/R/x86_64-redhat-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/readr_1.3.1.tar.gz'
Content type 'application/x-gzip' length 268853 bytes (262 KB)
==================================================
downloaded 262 KB

* installing *source* package ‘readr’ ...
** package ‘readr’ successfully unpacked and MD5 sums checked
** libs
g++ -m64  -I/usr/include/R -DNDEBUG  -I"/usr/lib64/R/library/Rcpp/include" -I"/usr/lib64/R/library/BH/include" -I/usr/local/include  -I. -Ircon -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c Collector.cpp -o Collector.o
virtual memory exhausted: Cannot allocate memory
make: *** [Collector.o] Error 1
ERROR: compilation failed for package ‘readr’
* removing ‘/home/jessica/R/x86_64-redhat-linux-gnu-library/3.4/readr’
Warning in install.packages :
  installation of package ‘readr’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmphwt8ya/downloaded_packages’
jessica
  • 1,325
  • 2
  • 21
  • 35
  • 1
    What output did you see after trying to install the `readr` package? Help us help you; we cannot help you solve an error message we cannot see. – duckmayr Apr 21 '19 at 20:28
  • 1
    It looks like you don't have enough memory to compile `readr`, meaning you may have to spring for a setup with more memory to install it. See, for example https://stackoverflow.com/questions/22819934/compiling-phalcon-virtual-memory-exhausted-cannot-allocate-memory or https://stackoverflow.com/questions/15193585/virtual-memory-exhausted-cannot-allocate-memory – duckmayr Apr 21 '19 at 20:40
  • 2
    this is a solved issue on GH. It sounds like your system has insufficient RAM. https://github.com/tidyverse/readr/issues/506 and https://github.com/tidyverse/readr/issues/544 – Wil Apr 21 '19 at 20:43
  • I do not believe that it is a ram issue because when I tried installing the xml2 package it gave me the same error. But when I installed it through the terminal it worked. I do not believe ram is an issue here. – jessica Apr 21 '19 at 21:20
  • 1
    Have you tried it with an instance with more RAM? The GitHub issues @Wil linked to suggest that others who had the same error you did were able to successfully install `readr` after trying an instance with 2 GB of RAM. – duckmayr Apr 21 '19 at 21:24
  • I just switched the instance from t2.micro to t2.medium – jessica Apr 21 '19 at 21:24
  • Actually nvm it did install after I switched it from t2.micro to t2.medium. Very odd because the xml2 gave the same error message but then installed through the terminal. Does installing through the terminal add more ram? I also can't figure out why some R packages need to be installed through the terminal while other through the Rstudio server. – jessica Apr 21 '19 at 21:31
  • 2
    I think there is some confusion about what `sudo yum install libxml2-devel` does. The R package `xml2` relies on the **system dependency** `libxml2` (see [here](https://cran.r-project.org/web/packages/xml2/index.html)). *That's* what sudo yum install libxml2-devel` satisfies; then `install.packages("xml2")` from R will work, either running R from RStudio Server or from the terminal. The `readr` package has no such system dependency (see [here](https://cran.r-project.org/web/packages/readr/index.html)), so your only issue was having enough RAM to compile it. – duckmayr Apr 21 '19 at 21:37

0 Answers0