Installation issue on a limux server, g++7.4, Makevars etc

Dear experts,

I am trying to install rstan on a linux server. RStan can be installed, but whenever I try to run it, I always receive the following error.

*** caught segfault ***
address 0x20, cause ‘memory not mapped’
Traceback:
1: Module(module, mustStart = TRUE)
2: .getModulePointer(x)
3: new(“Module”, .xData = )$stan_fit4model1608315cb9b_16a540c6086086816528e4524def24d9
4: new(“Module”, .xData = )stan_fit4model1608315cb9b_16a540c6086086816528e4524def24d9 5: eval(call("“, mod, paste(“stan_fit4”, model_cppname, sep = “”)))
6: eval(call(”$", mod, paste(“stan_fit4”, model_cppname, sep = “”)))
7: object@mk_cppmodule(object)
8: .local(object, …)
9: sampling(mod, data = list(y_mean = 0))
10: sampling(mod, data = list(y_mean = 0))
11: eval(ei, envir)
12: eval(ei, envir)
13: withVisible(eval(ei, envir))
14: source(tf, local, echo = echo, prompt.echo = paste0(prompt.prefix, getOption(“prompt”)), continue.echo = paste0(prompt.prefix, getOption(“continue”)), verbose = verbose, max.deparse.length = Inf, encoding = “UTF-8”, skip.echo = skips, keep.source = TRUE)
15: example(stan_model, run.dontrun = TRUE)

The g++ version on the server is 7.4.0, and I wonder if this has anything to do with my “Makevars” config?
I’ve tried a different Makevars config as Make: *** [lang__ast_def.o] Error 1 - #4 by stemangiola, but this did not solve the problem.

I have also tried to update Rcpp package, but it did not help at all.

Many thanks in advance,
Lei

The relevant info is shown below.

  • Operating System

CentOS Linux 7

  • RStan Version

2.18.2

  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))

CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=g++

  • Output of devtools::session_info("rstan")

─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 3.5.1 (2018-07-02)
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 Europe/Vienna
date 2019-04-01

─ Packages ───────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.5.1)
backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.1)
BH 1.69.0-1 2019-01-07 [1] CRAN (R 3.5.1)
callr 3.1.1 2018-12-21 [1] CRAN (R 3.5.1)
checkmate 1.9.1 2019-01-15 [1] CRAN (R 3.5.1)
cli 1.0.1 2018-09-25 [1] CRAN (R 3.5.1)
colorspace 1.4-0 2019-01-13 [1] CRAN (R 3.5.1)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.1)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.1)
digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.1)
fansi 0.4.0 2018-10-05 [1] CRAN (R 3.5.1)
ggplot2 * 3.1.0 2018-10-25 [1] CRAN (R 3.5.1)
glue 1.3.0 2018-07-17 [1] CRAN (R 3.5.1)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.5.1)
gtable 0.2.0 2016-02-26 [1] CRAN (R 3.5.1)
inline 0.3.15 2018-05-18 [1] CRAN (R 3.5.1)
labeling 0.3 2014-08-23 [1] CRAN (R 3.5.1)
lattice 0.20-38 2018-11-04 [3] CRAN (R 3.5.1)
lazyeval 0.2.1 2017-10-29 [1] CRAN (R 3.5.1)
loo 2.1.0 2019-03-13 [2] CRAN (R 3.5.1)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.1)
MASS 7.3-51.1 2018-11-01 [3] CRAN (R 3.5.1)
Matrix 1.2-15 2018-11-01 [1] CRAN (R 3.5.1)
matrixStats 0.54.0 2018-07-23 [1] CRAN (R 3.5.1)
mgcv 1.8-27 2019-02-06 [3] CRAN (R 3.5.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.1)
nlme 3.1-137 2018-04-07 [3] CRAN (R 3.5.1)
pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.1)
pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.5.1)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.1)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.5.1)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.1)
processx 3.2.1 2018-12-05 [1] CRAN (R 3.5.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.1)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.1)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.5.1)
Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.5.1)
RcppEigen 0.3.3.5.0 2018-11-24 [1] CRAN (R 3.5.1)
reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.5.1)
rlang 0.3.1 2019-01-08 [1] CRAN (R 3.5.1)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1)
rstan * 2.18.2 2018-11-07 [2] CRAN (R 3.5.1)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.1)
StanHeaders * 2.18.1 2019-01-28 [2] CRAN (R 3.5.1)
stringi 1.3.1 2019-02-13 [1] CRAN (R 3.5.1)
stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.1)
tibble 2.0.1 2019-01-12 [1] CRAN (R 3.5.1)
utf8 1.1.4 2018-05-24 [1] CRAN (R 3.5.1)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.5.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1)

[1] /apps/R/3.5.1/lib
[2] /home/user/zhang/R/x86_64-pc-linux-gnu-library/3.5
[3] /apps/R/3.5.1/lib64/R/library

g++-7 should be fine. Errors like this are usually caused by Rcpp (and maybe RcppEigen) being compiled (possibly in a distribution’s repo) with a different compiler and / or different compiler settings than what you have currently. In that case, it is usually sufficient to do

install.packages("Rcpp", type = "source")

in a clean R session followed by library(rstan) or whatever.