To be honest this is likely more of an rstudio question than an rstan question, but I am hoping there may be someone here who can help with my issue.
I am trying to get rstan setup on a linux cluster (RHEL 7.6). The only available gcc version was 4.8.5, so the administrators installed gcc version 7.2.0 for me. In ~/.profile I load the newer gcc version. Launching R from a bash terminal then correctly uses the new version of gcc and I can install and load rstan (2.18.2) successfully.
The issue I am having is that when trying to load rstan through rstudio server I get the following error:
library(rstan)
Error: package or namespace load failed for βrstanβ in dyn.load(file, DLLpath = DLLpath, β¦):
unable to load shared object β/home/cquirk/R/x86_64-redhat-linux-gnu-library/3.5/rstan/libs/rstan.soβ:
/lib64/libstdc++.so.6: version `CXXABI_1.3.8β not found (required by /home/cquirk/R/x86_64-redhat-linux-gnu-library/3.5/rstan/libs/rstan.so)
This occurs despite being able to successfully reinstall rstan through rstudio.
Here is some potentially relevant output:
$ cat ~/.R/Makevars
CXX14 = g++
CXX14FLAGS = -fPIC
$ cat ~/.Renviron
TMPDIR = /home/cquirk/TMPDIR
PATH = /usr/local/gcc/7.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
MANPATH = /usr/local/gcc/7.2.0/share/man
LD_LIBRARY_PATH = /usr/local/gcc/7.2.0/lib64:/usr/local/gcc/7.2.0/lib:/usr/lib64/R/lib:/lib:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
LIBRARY_PATH = /usr/local/gcc/7.2.0/lib64:/usr/local/gcc/7.2.0/lib
CPATH = /usr/local/gcc/7.2.0/include
CMAKE_PREFIX_PATH = /usr/local/gcc/7.2.0
CC = /usr/local/gcc/7.2.0/bin/gcc
CXX = /usr/local/gcc/7.2.0/bin/g++
FC = /usr/local/gcc/7.2.0/bin/gfortran
F77 = /usr/local/gcc/7.2.0/bin/gfortran
F90 = /usr/local/gcc/7.2.0/bin/gfortran
> Sys.getenv('LD_LIBRARY_PATH')
[1] β/usr/local/gcc/7.2.0/lib64:/usr/local/gcc/7.2.0/lib:/usr/lib64/R/lib:/lib:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/libβ
> devtools::session_info("rstan")
β Session info βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
setting value
version R version 3.5.1 (2018-07-02)
os Red Hat Enterprise Linux
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Chicago
date 2019-02-13
β Packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
package * version date lib source
assertthat 0.2.0 2017-04-11 [2] CRAN (R 3.5.0)
backports 1.1.3 2018-12-14 [2] 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)
cli 1.0.1 2018-09-25 [2] 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 [2] CRAN (R 3.5.0)
desc 1.2.0 2018-05-01 [2] CRAN (R 3.5.1)
digest 0.6.18 2018-10-10 [2] CRAN (R 3.5.1)
fansi 0.4.0 2018-10-05 [2] CRAN (R 3.5.1)
ggplot2 * 3.1.0 2018-10-25 [2] CRAN (R 3.5.1)
glue 1.3.0 2018-07-17 [2] CRAN (R 3.5.1)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.5.1)
gtable 0.2.0 2016-02-26 [2] CRAN (R 3.5.0)
inline 0.3.15 2018-05-18 [1] CRAN (R 3.5.1)
labeling 0.3 2014-08-23 [2] CRAN (R 3.5.0)
lattice 0.20-38 2018-11-04 [2] CRAN (R 3.5.1)
lazyeval 0.2.1 2017-10-29 [2] CRAN (R 3.5.0)
loo 2.0.0 2018-04-11 [1] CRAN (R 3.5.1)
magrittr 1.5 2014-11-22 [2] CRAN (R 3.5.0)
MASS 7.3-51.1 2018-11-01 [2] CRAN (R 3.5.1)
Matrix 1.2-15 2018-11-01 [2] CRAN (R 3.5.1)
matrixStats 0.54.0 2018-07-23 [1] CRAN (R 3.5.1)
mgcv 1.8-26 2018-11-21 [2] CRAN (R 3.5.1)
munsell 0.5.0 2018-06-12 [2] CRAN (R 3.5.0)
nlme 3.1-137 2018-04-07 [2] CRAN (R 3.5.1)
pillar 1.3.1 2018-12-15 [2] 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 [2] CRAN (R 3.5.1)
plyr 1.8.4 2016-06-08 [2] CRAN (R 3.5.0)
prettyunits 1.0.2 2015-07-13 [2] 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.3.0 2018-10-04 [2] CRAN (R 3.5.1)
RColorBrewer 1.1-2 2014-12-07 [2] CRAN (R 3.5.0)
Rcpp 1.0.0 2018-11-07 [2] CRAN (R 3.5.1)
RcppEigen 0.3.3.5.0 2018-11-24 [2] CRAN (R 3.5.1)
reshape2 1.4.3 2017-12-11 [2] CRAN (R 3.5.0)
rlang 0.3.1 2019-01-08 [1] CRAN (R 3.5.1)
rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.5.0)
rstan 2.18.2 2018-11-07 [1] CRAN (R 3.5.1)
scales 1.0.0 2018-08-09 [2] CRAN (R 3.5.1)
StanHeaders * 2.18.1 2019-01-28 [1] CRAN (R 3.5.1)
stringi 1.2.4 2018-07-20 [2] CRAN (R 3.5.1)
stringr 1.3.1 2018-05-10 [2] CRAN (R 3.5.0)
tibble 2.0.1 2019-01-12 [1] CRAN (R 3.5.1)
utf8 1.1.4 2018-05-24 [2] CRAN (R 3.5.0)
viridisLite 0.3.0 2018-02-01 [2] CRAN (R 3.5.0)
withr 2.1.2 2018-03-15 [2] CRAN (R 3.5.0)
[1] /home/cquirk/R/x86_64-redhat-linux-gnu-library/3.5
[2] /usr/lib64/R/library
[3] /usr/share/R/library
It seems as if rstudio is not respecting my LD_LIBRARY_PATH. The administrator confirmed that if LD_LIBRARY_PATH is set in in the global RStudio Server configuration file (in a test environment) everything seems to work correctly. I am apparently not the first person to have this issue, but it seems like all of the solutions require a global change to the RStudio Server configuration and making a system wide change for this issue is probably not going to be possible. So I am somewhat stuck (at least in terms of using rstudio server, which I have a strong preference for).
Like I said, I realize this isnβt strictly an rstan issue but Iβd appreciate any advice anyone can offer.