Unable to complete rstan installation / run either rstanarm or brms [ mac + catalina ]

Hi everyone,

I am stuck with not being able to properly install Rstan. I have read and done the instructions in github and here in discourse multiple times, reinstalled R + RStudio more than once, but it still does not work. It has been many hours already trying to repeat the same steps, and so frustrating that with previous OS it was working fine. Anyway.

I have been through the forum, tried to adjust the Makevars, but it does not work either. Any guidance much appreciated!

  • Panos

Here is my system info and steps I have completed.

Operating System: Mac OS, Catalina 10.15.6
Interface Version: rstan 2.19.2 ( 2.21.1 refuses to compile see below)
Compiler/Toolkit: not sure
xcode-select version 2373
R 3.6.3 (downgraded from 4.0 because it was not working)
Rstudio 1.3 (latest)

Steps done:

The errors:

Simple brms

datate = data.frame( a = rnorm(100, 1), b = c(rep(0, 50), rep(1, 50)))
brm(bf(a~b), datate, cores = 1, chains = 4)


chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
[1] “Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done

Then if I try to install rstanarm, I get 100s of lines with warnings and errors like this:

ibrary/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/squared_distance.hpp:27:11: warning: unused type alias ‘idx_t’ [-Wunused-local-typedef]
using idx_t = typename index_type<matrix_v>::type;
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/squared_distance.hpp:64:11: warning: unused type alias ‘idx_t’ [-Wunused-local-typedef]
using idx_t = typename index_type<matrix_d>::type;
In file included from stan_files/bernoulli.cc:3:
stan_files/bernoulli.hpp:2651:24: warning: unused typedef ‘local_scalar_t__’ [-Wunused-local-typedef]
typedef double local_scalar_t__;

Session info

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] StanHeaders_2.21.0-6 brms_2.13.5          Rcpp_1.0.5.2        

loaded via a namespace (and not attached):
 [1] nlme_3.1-144          matrixStats_0.57.0    xts_0.12.1            threejs_0.3.3        
 [5] rstan_2.21.2          tools_3.6.3           backports_1.1.10      R6_2.4.1             
 [9] DT_0.15               colorspace_1.4-1      withr_2.3.0           tidyselect_1.1.0     
[13] gridExtra_2.3         prettyunits_1.1.1     processx_3.4.4        Brobdingnag_1.2-6    
[17] emmeans_1.5.1         curl_4.3              compiler_3.6.3        cli_2.0.2            
[21] shinyjs_2.0.0         sandwich_3.0-0        colourpicker_1.1.0    scales_1.1.1         
[25] dygraphs_1.1.1.6      mvtnorm_1.1-1         ggridges_0.5.2        callr_3.4.4          
[29] stringr_1.4.0         digest_0.6.25         base64enc_0.1-3       pkgconfig_2.0.3      
[33] htmltools_0.5.0       fastmap_1.0.1         htmlwidgets_1.5.2     rlang_0.4.7          
[37] rstudioapi_0.11       shiny_1.5.0           generics_0.0.2        zoo_1.8-8            
[41] jsonlite_1.7.1        crosstalk_1.1.0.1     gtools_3.8.2          dplyr_1.0.2          
[45] inline_0.3.16         magrittr_1.5          loo_2.3.1             bayesplot_1.7.2      
[49] Matrix_1.2-18         munsell_0.5.0         fansi_0.4.1           abind_1.4-5          
[53] lifecycle_0.2.0       stringi_1.5.3         multcomp_1.4-14       MASS_7.3-51.5        
[57] pkgbuild_1.1.0        plyr_1.8.6            grid_3.6.3            parallel_3.6.3       
[61] promises_1.1.1        crayon_1.3.4          miniUI_0.1.1.1        lattice_0.20-38      
[65] splines_3.6.3         ps_1.4.0              pillar_1.4.6          igraph_1.2.6         
[69] markdown_1.1          estimability_1.3      shinystan_2.5.0       reshape2_1.4.4       
[73] codetools_0.2-16      stats4_3.6.3          rstantools_2.1.1.9000 glue_1.4.2           
[77] V8_3.2.0              RcppParallel_5.0.2    vctrs_0.3.4           httpuv_1.5.4         
[81] gtable_0.3.0          purrr_0.3.4           assertthat_0.2.1      ggplot2_3.3.2        
[85] mime_0.9              xtable_1.8-4          coda_0.19-4           later_1.1.0.1        
[89] rsconnect_0.8.16      survival_3.1-8        tibble_3.0.3          shinythemes_1.1.2    
[93] TH.data_1.0-10        ellipsis_0.3.1        bridgesampling_1.0-0 

For Macs, getting all the Stan-related packages to work with R 3.x is much more difficult than getting them to work with R 4.x. What are the errors you are getting with R 4.x?

Let me install it again and will get back to you!

OK, that was it!
Upgrading again to R 4.0 again, and rstan_2.21.1 solved the problem.

It was simple in the end, but many thanks for the quick reaction!