I can't seem to install raster package on ubuntu 16.04 server

I'm trying to get a web app running on an amazon ubuntu server. I need to install the raster package, but R seems to freeze whenever I try at this point:

$ sudo su - -c "R -e "install.packages('raster')""

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

install.packages('raster', repos='https://cran.rstudio.com/')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/raster_2.9-5.tar.gz'
Content type 'application/x-gzip' length 971151 bytes (948 KB)
downloaded 948 KB

  • installing source package ‘raster’ ...
    ** package ‘raster’ successfully unpacked and MD5 sums checked
    ** libs
    g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RasterModule.cpp -o RasterModule.o

Can anyone help me?

Thanks in advance!

You are not showing any error message, if your ec2 instance has limited resources, then maybe you just have to wait for the library to compile. Have you checked with htop on a separate terminal if your cores are busy while installing? Is your ram memory completely allocated during installation?

this is what happens in the end, after waiting for hours:
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
/usr/lib/R/etc/Makeconf:168: recipe for target 'RasterModule.o' failed
make: *** [RasterModule.o] Error 4
ERROR: compilation failed for package ‘raster’

  • removing ‘/usr/local/lib/R/site-library/raster’

The downloaded source packages are in

Have you checked your allocated RAM memory during installation? this could be happening because of you running out of memory, how much memory do you have in your ec2 instance?
You could try to add some more SWAP memory and see if this helps.

1 Like

Consider temporarily using a bigger AWS instance. Micro (the free one) does not have enough memory to compile {raster} . It can run it, but for installation you need a small or medium instance. AWS bills per second, and you will need just a couple minutes.

1 Like

Yes, this solved it!
Thanks so much, fieldwork is saved now :smiley:

Yes, this worked like a charm! Thanks for sharing the tweet as well, I didn't bump into this problem when I installed the raster package a couple of months ago!
Fieldwork is saved :smiley: Thanks a lot!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.