Issues with Shiny and Leaflet on an AWS EC2

As described in the title, I'm having issues with installing the package 'leaflet' on my shiny server (on an EC2).

** package ‘ggplot2’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ggplot2)
* installing *source* package ‘viridis’ ...
** package ‘viridis’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (viridis)
ERROR: dependency ‘raster’ is not available for package ‘leaflet’
* removing ‘/home/shiny/R/x86_64-pc-linux-gnu-library/3.4/leaflet’

The downloaded source packages are in
	‘/tmp/RtmpeFj1fk/downloaded_packages’
Warning message:
In install.packages("leaflet") :
  installation of package ‘leaflet’ had non-zero exit status
> install.packages("raster")
Installing package into ‘/home/shiny/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Warning message:
package ‘raster’ is not available (for R version 3.4.4) 
> 

A dependency for leaflet, 'raster', is not available; however, I am also unable to download it as a package through R, as demonstrated.

Could someone kindly address this issue for me?

The raster package depends on R >= 3.5.0 so you need to update your R version.

That's what I had assumed, but I'm unsure how I would go about doing this on this Ubuntu 18.04 instance -- and I have added a public key to the system I believe.

You have to add a repository to your /etc/apt/sources.list file

sudo nano /etc/apt/sources.list

Add this line and save the file

deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/

Then add the apt key

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

update your apt cache and install R

sudo apt update
sudo apt install r-base r-base-dev
1 Like

It also seems that I have this issue:

g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-7BvS0x/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RasterModule.cpp -o RasterModule.o

Freezes on this chunk of code, which I believe had also happened earlier. Any idea what this could be?

I appreciate the help though!

Edit: In the monitoring portion of my AWS instance, it seems as though the CPU reaches ~100% utilization when trying to install the "leaflet" library, which leads to this crash.

EDIT: Seems as though the basic ec2.micro's memory is the issue here...

Sorry but you are not showing any error message, if the cpu is working then maybe you simply have to wait longer, a t2.micro is a very underpowered instance but it is more than capable of compiling leaflet (I have tested it), if your issue where lack of memory then the compiler should stop with a kill message, but even if that was the case you could add swap memory to solve it.

I was able to debug successfully; ended up upgrading to a t2.medium to download the packages. Everything is running just fine as of now!

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.