Error while running example code after successful installation of rstan on linux

Hi all,

I recently installed rstan on a linux cluster and successfully installed the package in my home directory since I wasn’t allowed to install it in the root directory using: install.packages(“rstan”, type = “source”)

However, while running the example code:

stancode <- ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’
mod <- stan_model(model_code = stancode, verbose = TRUE)

I get the following error at the end:

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file80c7f53fb3b.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
#define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
^
In file included from /opt/R/local/lib/RcppEigen/include/Eigen/Core:383:0,
from /opt/R/local/lib/RcppEigen/include/Eigen/Dense:1,
from /home/sshres/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
from :0:
/opt/R/local/lib/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument ‘__m128 {aka __vector(4) float}’ [-Wignored-attributes]
template<> struct is_arithmetic<__m128> { enum { value = true }; };
^
/opt/R/local/lib/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignoring attributes on template ar

Some information on the system is:

  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))):
    CXX14FLAGS=-O3 -Wno-unused-variable -Wno-unused-function -fPIC
    CXX14 = g++ -std=c++1y

  • Output of devtools::session_info("rstan"):
    ─ Session info
    setting value
    version R version 3.6.1 (2019-07-05)
    os CentOS Linux 7 (Core)
    system x86_64, linux-gnu
    ui X11
    language (EN)
    collate en_US.UTF-8
    ctype en_US.UTF-8
    tz America/Los_Angeles
    date 2020-03-06

─ Packages
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1)
BH 1.69.0-1 2019-01-07 [1] CRAN (R 3.6.1)
callr 3.3.2 2019-09-22 [1] CRAN (R 3.6.1)
checkmate 1.9.4 2019-07-04 [1] CRAN (R 3.6.1)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.1)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)
digest 0.6.21 2019-09-20 [1] CRAN (R 3.6.1)
ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1)
fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.1)
ggplot2 * 3.2.1 2019-08-10 [1] CRAN (R 3.6.1)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.6.1)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.1)
inline 0.3.15 2018-05-18 [2] CRAN (R 3.6.1)
labeling 0.3 2014-08-23 [1] CRAN (R 3.6.1)
lattice 0.20-38 2018-11-04 [3] CRAN (R 3.6.1)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.1)
loo 2.2.0 2019-12-19 [2] CRAN (R 3.6.1)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
MASS 7.3-51.4 2019-03-31 [3] CRAN (R 3.6.1)
Matrix 1.2-17 2019-03-22 [3] CRAN (R 3.6.1)
matrixStats 0.55.0 2019-09-07 [1] CRAN (R 3.6.1)
mgcv 1.8-28 2019-03-21 [3] CRAN (R 3.6.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.1)
nlme 3.1-141 2019-08-01 [1] CRAN (R 3.6.1)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.1)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.1)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.1)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.1)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.1)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.6.1)
Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1)
RcppEigen 0.3.3.5.0 2018-11-24 [1] CRAN (R 3.6.1)
reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.6.1)
rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.1)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)
rstan * 2.19.3 2020-02-11 [2] CRAN (R 3.6.1)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.1)
StanHeaders * 2.19.2 2020-02-11 [2] CRAN (R 3.6.1)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.1)
stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.1)
utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.1)
vctrs 0.2.0 2019-07-05 [1] CRAN (R 3.6.1)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1)
zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.1)

[1] /opt/R/local/lib
[2] /home/sshres/R/x86_64-pc-linux-gnu-library/3.6
[3] /opt/R/lib64/R/library

g++ --version give g++ (GCC) 7.2.0

Any help would be much appreciated!

Best,
Sama

I think it will work if you upgrade your BH.

Upgrading the BH worked. More specifically, loading the newer version from my home library did the trick.

Thank you so much :)