Rstanarm: CRAN vs Development version installation issues

Elite. Thank you. Worked well.

Thanks for solving this Ben! I sort of wonder whether it is worth having something in the Wiki (or somewhere similar) about installing the feature/survival development branch, since this might keep happening a bit otherwise.

1 Like

I am continuing this thread as I have problems installing the feature/survival branch from Github on OSX Catalina.

I followed Rstan getting started and Installing Rstan from source on a Mac, installed first the macOS R toolchain, then Rcpp and Rstan (version 2.19.3) with

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

After this I have succesfully installed and used rstanarm from CRAN

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

Also these installations succeed

devtools::install_github("stan-dev/rstanarm", build_vignettes = FALSE)

However, when I try to install the feature/survival branch from github, it fails:

devtools::install_github("stan-dev/rstanarm@feature/survival", build_vignettes = FALSE)

(Note that below I show only the end of the R output. The full log is very long, as it has some seemingly unrelated warnings that also show up in the successful installations)

** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘rstanarm’ in dyn.load(file, DLLpath = DLLpath, …):
unable to load shared object ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-rstanarm/00new/rstanarm/libs/’:
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-rstanarm/00new/rstanarm/libs/, 6): Symbol not found: __ZN20model_polr_namespace24csr_matrix_times_vector2IdN4stan4math3varEEEN5Eigen6MatrixIN5boost4math5tools12promote_argsIT_T0_ffffE4typeELin1ELi1ELi0ELin1ELi1EEERKiSG_RKNS5_ISA_Lin1ELi1ELi0ELin1ELi1EEERKNSt3__16vectorIiNSK_9allocatorIiEEEESQ_RKNS5_ISB_Lin1ELi1ELi0ELin1ELi1EEEPNSK_13basic_ostreamIcNSK_11char_traitsIcEEEE
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-rstanarm/00new/rstanarm/libs/
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/3.6/Resources/library/00LOCK-rstanarm/00new/rstanarm/libs/
Error: loading failed
Execution halted
ERROR: loading failed
removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rstanarm’
Error: Failed to install ‘rstanarm’ from GitHub:
(converted from warning) installation of package ‘/var/folders/st/bd1mw1z533d4pwb1xxd2vf540000gn/T//RtmpSpPhb2/file15724720f6586/rstanarm_2.19.1.tar.gz’ had non-zero exit status

The same happens if I download the repo and try to install it manually from Rstudio.

This error message seems very similar to the one reported here, but that did not help me forward.

Curiously, I was able to install and use the survival branch on Debian GNU/Linux 10 (buster).

So I have a problem that seems to be specific to the survival branch and OSX. Could it be that rstanarm master branch has been updated recently to cope with OSX Catalina, but the survival branch has not? Or maybe the survival branch is incompatible with rstan version 2.19.3, and I should install an older rstan version first?

Could either @sambrilleman or @bgoodri help me out here?

I managed to solve the issue at least partially. The problem appears to be some lines in my .R/Makevars.

After my initial installation of rstan and rstanarm(2.19.3.), I had updated my .R/Makevars based on this and this (if I remember correctly), and it looked like this:

# clang: start
CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/l$

SHLIB_CXXLDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
SHLIB_CXX11LDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib

# clang: end

CXX14FLAGS=-O3 -march=native -mtune=native
CXX14FLAGS += -arch x86_64 -ftemplate-depth-256

After commenting out all lines in .R/Makevars, I managed to successfully install the survival branch with

devtools::install_github("stan-dev/rstanarm@feature/survival", build_vignettes = FALSE)

and it seems to work properly.

However, trying to install the downloaded repo manually from RStudio produces the same error as above.

I am also having trouble installing the development version of rstanarm. I’m working on a windows 10 machine with 32gb of ram, but get the following error after running

devtools::install_github("stan-dev/rstanarm",ref = "feature/survival", build_vignettes = FALSE)

cc1plus.exe: out of memory allocating 15696248 bytes
make: *** [C:/PROGRA~1/R/R-40~1.1/etc/i386/Makeconf:227: stan_files/jm.o] Error 1
rm stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/
ERROR: compilation failed for package ‘rstanarm’

Trying to install from the downloaded zipfile has the identical result.

Are you using R4.0 and rtools4? These kinds of errors can occur when upgrading your R and RTools version to the latest versions.

Can you try the instructions in the post below and see if they fix the problem?

I am using rtools4 and R version 4.0.1.

I followed these instructions and am having the same problem.

Alrighty, just to check the existing configuration, can you post the outputs from the following commands:






[1] “”


[1] “C:\rtools40\usr\bin;C:\Program Files\R\R-4.0.1\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Rtools\bin;C:\Program Files\ImageMagick-7.0.9-Q16;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;c:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;c:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Users\shauh\AppData\Local\Microsoft\WindowsApps;”


[1] “” “CXX14FLAGS=-O3 -march=corei7 -mtune=corei7”
[3] “CXX14 = (BINPREF)g++ -m(WIN) -std=c++1y” “CXX11FLAGS=-O3 -march=corei7 -mtune=corei7”

Can you remove this line from your file:

“CXX14 = (BINPREF)g++−m (WIN) -std=c++1y”

Then restart R and try again?

Sorry, I’m not sure how to do that. Could you please explain how to implement that?

In your ‘My Documents’ folder, you should have a folder called ‘.R’, in that folder will be your file. If you open that with a text editor (like Notepad), you can remove the line that I mentioned

Thanks for that. I removed that line and tried to install rstanarm again but get the identical problem.

Can you check if the RStan example model compiles and samples:

example(stan_model,run.dontrun = TRUE,verbose=TRUE)

Looks like it compiled successfully

That means the compiler and Stan installation are all working well, so the issue is elsewhere.

Looking at the original error, it looks like it only ran out of memory by ~15mb. This can happen if you’re compiling multiple models simultaneously, with each model taking ~2-3gb.

Can you trying installing with fewer cores:

devtools::install_github("stan-dev/rstanarm",ref = "feature/survival", build_vignettes = FALSE)

Same issue infortunately

cc1plus.exe: out of memory allocating 15636264 bytes
make: *** [C:/PROGRA~1/R/R-40~1.1/etc/i386/Makeconf:227: stan_files/jm.o] Error 1
rm stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/ stan_files/
ERROR: compilation failed for package ‘rstanarm’
removing ‘C:/Users/shauh/Documents/R/win-library/4.0/rstanarm’
Error: Failed to install ‘rstanarm’ from GitHub:
(converted from warning) installation of package ‘C:/Users/shauh/AppData/Local/Temp/RtmpWQjLOl/file2c7862e42f7e/rstanarm_2.19.1.tar.gz’ had non-zero exit status
In addition: Warning message:
In utils::untar(tarfile, …) :
‘tar.exe -xf “C:\Users\shauh\AppData\Local\Temp\RtmpWQjLOl\file2c7818aa2ef6.tar.gz” -C “C:/Users/shauh/AppData/Local/Temp/RtmpWQjLOl/remotes2c78789e2e32”’ returned error code 1

Hm, I’m afraid I’m not sure what the issue is then. If your compiler and RStan installation are working without issue, it might have something to do with the rstanarm installation itself.

@bgoodri or @jonah might be able to help you here

Compiling rstanarm from source takes a lot of RAM, although it will use less once I get rstan 2.21 onto CRAN to go with the StanHeaders 2.21.

My machine has 32gb of RAM, you think it needs more than that?