8 schools example aborting R

I am using linux in a cluster and have installed rstan as per instructions using:

g++
gcc version 5.3.0 (GCC)

Makevars
CXXFLAGS += -std=c++11 # found this in a previous post,

##the suggested cat("\nCXXFLAGS+=-flto -ffat-lto-objects -Wno-unused-local-typedefs", file = M, sep = “\n”, append = TRUE) didnt work for me ###

> library(rstan) Seems to me that is properly installed
Loading required package: ggplot2
Want to understand how all the pieces fit together? Buy the ggplot2
book: http://ggplot2.org/book/
Loading required package: StanHeaders
rstan (Version 2.16.2, packaged: 2017-07-03 09:24:58 UTC, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())

sessionInfo()

R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux release 6.9 (Carbon)

locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rstan_2.16.2 StanHeaders_2.16.0-1 ggplot2_2.2.1

loaded via a namespace (and not attached):
[1] colorspace_1.3-2 scales_0.4.1 lazyeval_0.2.0 plyr_1.8.4
[5] inline_0.3.14 gtable_0.2.0 tibble_1.3.3 gridExtra_2.2.1
[9] Rcpp_0.12.12 grid_3.3.2 stats4_3.3.2 rlang_0.1.1
[13] munsell_0.4.3

** Running stan**

schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
fit <- stan(file = ‘/home/ev250/Bayesian_inf/learn_stan/Scripts/8schools.stan’, data = schools_dat, iter = 1000, chains = 1, verbose=T)

**I run the stan command with 1 or 16 cores, 1 or 4 chains but always get the same output.

error message
TRANSLATING MODEL ‘8schools’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘8schools’.

CHECKING DATA AND PREPROCESSING FOR MODEL ‘8schools’ NOW.

COMPILING MODEL ‘8schools’ NOW.

*** caught segfault ***
address 0x20, cause ‘memory not mapped’

Traceback:
1: .Call(Module__classes_info, xp)
2: Module(module, mustStart = TRUE)
3: .getModulePointer(x)
4: <S4 object of class “Module”>$stan_fit4modelfdc33509d21b_8schools
5: <S4 object of class “Module”>$stan_fit4modelfdc33509d21b_8schools
6: eval(expr, envir, enclos)
7: eval(call("$", mod, paste(“stan_fit4”, model_cppname, sep = “”)))
8: object@mk_cppmodule(object)
9: .local(object, …)
10: sampling(sm, data, pars, chains, iter, warmup, thin, seed, init, check_data = TRUE, sample_file = sample_file, diagnostic_file = diagnostic_file, verbose = verbose, algorithm = match.arg(algorithm), control = control, check_unknown_args = FALSE, cores = cores, open_progress = open_progress, include = include, …)
11: sampling(sm, data, pars, chains, iter, warmup, thin, seed, init, check_data = TRUE, sample_file = sample_file, diagnostic_file = diagnostic_file, verbose = verbose, algorithm = match.arg(algorithm), control = control, check_unknown_args = FALSE, cores = cores, open_progress = open_progress, include = include, …)
12: stan(file = “/home/ev250/Bayesian_inf/learn_stan/Scripts/8schools.stan”, data = schools_dat, iter = 1000, chains = 1, verbose = T)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

You need the Rcpp package to be compiled with the same compiler settings.

Thanks! I am not sure if I understand… sorry… do you mean to install the Rcpp package in R?

I tried but didnt work, see below. The error message suggests to rm /home/ev250/R/x86_64-pc-linux-gnu-library/3.3/00LOCK-Rcpp, but because I am not sure if this is what you meant to do I thought to ask first.

Many thanks indeed for your time!

>install.packages("Rcpp")

Installing package into ‘/home/ev250/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://mirrors.ebi.ac.uk/CRAN/src/contrib/Rcpp_0.12.12.tar.gz'
Content type 'application/x-gzip' length 2421289 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

ERROR: failed to lock directory ‘/home/ev250/R/x86_64-pc-linux-gnu-library/3.3’ for modifying
Try removing ‘/home/ev250/R/x86_64-pc-linux-gnu-library/3.3/00LOCK-Rcpp’

[edit: added code escapes]

Ok, it is working now. I uninstall Rcpp and re-install it using the command below and rstan is running,

thanks all for your help!

install.packages(“Rcpp”, dependencies=TRUE, INSTALL_opts = c(‘–no-lock’))