Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R (Ubuntu) - Can't install packages "readr" and "eurostat"

I have a problem with installing "eurostats" package in R. After breaking down the problem, I deduced that the problem lies with "readr" package. Trying to install it, this occurs:

* installing *source* package ‘readr’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/home/shiny/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include" -I"/home/shiny/R/x86_64-pc-linux-gnu-library/3.3/BH/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c Collector.cpp -o Collector.o

after which the terminal just freezes as if it is active but nothing happens.Prior to this, I kind of tackled with locale settings (just mentioning it if it helps). I was able to install other packages.

My R and Linux details are as follows:

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] httr_1.2.1      R6_2.2.0        tools_3.3.2     withr_1.0.2    
[5] curl_2.2        memoise_1.0.0   git2r_0.16.0    digest_0.6.10  
[9] devtools_1.12.0

Could someone please help me?

like image 926
ilitse Avatar asked Dec 03 '16 07:12

ilitse


2 Answers

You have insufficient RAM on that machine. So you have two options:

  • continue what you are doing and trying to compile from source, which will need more memory and is likely to fail

  • install a prebuilt binary (!!) so that you do not have to compile in the first place

The easiest way is something like this (and I am showing only the commands, not the output while I do this in a Docker instance of Ubuntu 16.04, and I am doing this in Docker where the account is root; otherwise add sudo in front)

apt-get update     # refresh
apt-get install software-properties-common
add-apt-repository -y "ppa:marutter/rrutter"
add-apt-repository -y "ppa:marutter/c2d4u"
apt-get update     # now with new repos
apt-get install r-cran-readr

and voila you have the readr package. Now proceed for eurostat which is not packaged as a binary, but may not require heavier resources which readr does due to its C++ code.

like image 81
Dirk Eddelbuettel Avatar answered Nov 17 '22 22:11

Dirk Eddelbuettel


I had the same problem on my raspberry pi. The workaround was to increase the size of the swap (in my case to 1Gb). Here are the steps:

sudo swapon -s #get size and filename
sudo swapoff -a #stop the actual swaps
sudo fallocate -l 1g swap2 #allocate 1Gb for the swapfile
sudo mkswap swap2
sudo swapon swap2

Start R and install your packages.

If you need to get back to your previous config:

sudo swapoff -a
sudo rm swap2
sudo swapon your-previous-swap
like image 29
Kevin Zarca Avatar answered Nov 17 '22 21:11

Kevin Zarca