I am trying to install R
library for Facebook's prophet
on centOS 7. For easy reproducibility, I am providing a dockerfile
and commands.
FROM centos:7
RUN yum -y install epel-release
RUN yum -y groupinstall "Development Tools"
RUN yum -y install proj
RUN yum -y install udunits2-devel
RUN yum -y install openssl-devel
RUN yum -y install libjpeg-turbo-devel
RUN yum -y install libcurl-devel
RUN yum -y install v8-devel
RUN yum -y install R
To build the dockerfile, use following command.
docker build -t test_prophet_installation .
Once it is built, I run the container using this next command.
docker run -it --entrypoint=/bin/bash test_prophet_installation
Now, I am inside my container. I tried to install prophet
using below command.
su - -c "R -e \"install.packages('prophet', repos='http://cran.rstudio.com/')\""
The above command said, one of the dependencies of prophet
i.e rstan
failed to install. So I tried to install 'rstan' using the following command.
su - -c "R -e \"install.packages('rstan', repos='http://cran.rstudio.com/')\""
After running the above command, I got the following error.
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined
* removing '/usr/lib64/R/library/rstan'
The downloaded source packages are in
'/tmp/RtmpsPDQ9G/downloaded_packages'
Updating HTML index of packages in '.Library'
Warning messages:
1: In install.packages("rstan", repos = "http://cran.rstudio.com/") :
installation of package 'rstan' had non-zero exit status
2: In file.create(f.tg) :
cannot create file '/usr/share/doc/R-3.6.0/html/packages.html', reason 'No such file or directory'
3: In make.packages.html(.Library) : cannot update HTML package index
I tried almost all the troubleshooting from Google to solve above error still no luck. I think, I am not setting some environment variable correctly.
The problem here is that when using the
yum groupinstall "Development Tools"
, the installed gcc is 4.8.5 and therefore does not support C++14 (as you can see here).In order to solve this you need to add the following:
on top of this, you have to define the Makevars for
rstan
. You can find an explanation here: https://github.com/stan-dev/rstan/issues/569I created this Makevars:
and added a COPY in my Dockerfile:
I'm using the following command to download the packages:
Some things are still not working as expected but it's a step forward.
EDIT: this approach does not work since the system keeps using the old g++. I ended up using the docker image
centos/devtoolset-7-toolchain-centos7:latest
.