Rstan installation on RHEL 6

rstan

#1

Hi, I am trying to setup rstan r-3.5 hosted on RHEL 6 and so far its failing with error:
Command used to install:
install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

Error:
ERROR: dependency ‘igraph’ is not available for package ‘threejs’
ERROR: dependency ‘threejs’ is not available for package ‘shinystan’

The downloaded source packages are in
‘/tmp/RtmpPeWCSs/downloaded_packages’
Updating HTML index of packages in ‘.Library’
Making ‘packages.html’ … done
Warning messages:
1: In install.packages(“rstan”, repos = “https://cloud.r-project.org/”, :
installation of package ‘igraph’ had non-zero exit status
2: In install.packages(“rstan”, repos = “https://cloud.r-project.org/”, :
installation of package ‘threejs’ had non-zero exit status
3: In install.packages(“rstan”, repos = “https://cloud.r-project.org/”, :
installation of package ‘shinystan’ had non-zero exit status

can someone please assist


#2

I tried to reinstall and had updated PATH and received below error:

installing to /opt/R/3.5.0/lib64/R/library/igraph/libs
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded

  • DONE (igraph)
  • installing source package ‘rstan’ …
    ** package ‘rstan’ successfully unpacked and MD5 sums checked
    ** libs
    Error in .shlib_internal(args) :
    C++14 standard requested but CXX14 is not defined
  • removing ‘/opt/R/3.5.0/lib64/R/library/rstan’
  • restoring previous ‘/opt/R/3.5.0/lib64/R/library/rstan’
  • installing source package ‘threejs’ …
    ** package ‘threejs’ successfully unpacked and MD5 sums checked
    ** R
    ** data
    ** demo
    ** inst
    ** byte-compile and prepare package for lazy loading
    Creating a generic function for ‘vertices’ from package ‘igraph’ in package ‘threejs’
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
  • DONE (threejs)
  • installing source package ‘shinystan’ …
    ** package ‘shinystan’ successfully unpacked and MD5 sums checked
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    *** copying figures
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
  • DONE (shinystan)

The downloaded source packages are in
‘/tmp/Rtmpaxharv/downloaded_packages’
Updating HTML index of packages in ‘.Library’
Making ‘packages.html’ … done
Warning message:
In install.packages(“rstan”, repos = “https://cloud.r-project.org/”, :
installation of package ‘rstan’ had non-zero exit status


#3

Same as


#4

Thanks!! I have gone through
https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux#c-toolchain-configuration and have the g++ version as 4.9

g++ --version
g++ (GCC) 4.9.2 20150212

After this I ran the following in R console and received the same error:

>dotR <- file.path(Sys.getenv(“HOME”), “.R”)
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, ifelse(.Platform$OS.type == “windows”, “Makevars.win”, “Makevars”))
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native",
if( grepl("^darwin", R.version$os)) “CXX14FLAGS += -arch x86_64 -ftemplate-depth-256” else
if (.Platform$OS.type == “windows”) “CXX11FLAGS=-O3 -march=native -mtune=native” else
“CXX14FLAGS += -fPIC”,
file = M, sep = “\n”, append = TRUE)> > > > + + + +
>install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

Error:
Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined


#5

OK. Try adding this line CXX14 = g++ to the ~/.R/Makevars file with a text editor.


#6

I have created Makevars file under home/.R/ with the content specified above.:

>more Makevars
CXX14 = g++

The I ran below command in R console and received error:

> dotR <- file.path(Sys.getenv(“HOME”), “.R”)
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, ifelse(.Platform$OS.type == “windows”, “Makevars.win”, “Makevars”))
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native",
if( grepl("^darwin", R.version$os)) “CXX14FLAGS += -arch x86_64 -ftemplate-depth-256” else
if (.Platform$OS.type == “windows”) “CXX11FLAGS=-O3 -march=native -mtune=native” else
“CXX14FLAGS += -fPIC”,
file = M, sep = “\n”, append = TRUE)> > + + + +
> install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

I received below error now:

make: *** [/opt/R/3.5.0/lib64/R/etc/Makeconf:168: lang__ast_def.o] Error 1
ERROR: compilation failed for package ‘rstan’

  • removing ‘/opt/R/3.5.0/lib64/R/library/rstan’
  • restoring previous ‘/opt/R/3.5.0/lib64/R/library/rstan’

The downloaded source packages are in
‘/tmp/RtmpzMKFzF/downloaded_packages’
Updating HTML index of packages in ‘.Library’
Making ‘packages.html’ … done
Warning message:
In install.packages(“rstan”, repos = “https://cloud.r-project.org/”, :
installation of package ‘rstan’ had non-zero exit status


#7

Perhaps change the line in ~/.R/Makevars to

CXX = g++ -std=c++1y

#8

Thanks, I tried the mention steps and it failed with error:

more Makevars
CXX = g++ -std=c++1y

> dotR <- file.path(Sys.getenv(“HOME”), “.R”)
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, ifelse(.Platform$OS.type == “windows”, “Makevars.win”, “Makevars”))
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native",
if( grepl("^darwin", R.version$os)) “CXX14FLAGS += -arch x86_64 -ftemplate-depth-256” else
if (.Platform$OS.type == “windows”) “CXX11FLAGS=-O3 -march=native -mtune=native” else
“CXX14FLAGS += -fPIC”,
file = M, sep = “\n”, append = TRUE)> > + + + +
> install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

I received below error::

Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined

  • removing ‘/opt/R/3.5.0/lib64/R/library/rstan’
  • restoring previous ‘/opt/R/3.5.0/lib64/R/library/rstan’

The downloaded source packages are in
‘/tmp/Rtmp4d65Sa/downloaded_packages’
Updating HTML index of packages in ‘.Library’
Making ‘packages.html’ … done
Warning message:
In install.packages(“rstan”, repos = “https://cloud.r-project.org/”, :
installation of package ‘rstan’ had non-zero exit status


#9

Sorry. I meant to say

CXX14 = g++ -std=c++1y

#10

In Ubuntu 16.04. gcc 5.4 I faced some problems with the -std==c++1y flag, used instead:
CXX14 = g++ -std=gnu++14