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

**URL:** <https://discourse.mc-stan.org/t/unable-to-complete-rstan-installation-run-either-rstanarm-or-brms-mac-catalina/18511>\
**Category:** Interfaces\
**Tags:** installation, rstan\
**Created:** [October 8, 2020, 1:13pm UTC](https://discourse.mc-stan.org/t/unable-to-complete-rstan-installation-run-either-rstanarm-or-brms-mac-catalina/18511 "2020-10-08T13:13:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmavros](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@pmavros](https://discourse.mc-stan.org/u/pmavros)\
**Post date:** [October 8, 2020, 1:13pm UTC](https://discourse.mc-stan.org/t/unable-to-complete-rstan-installation-run-either-rstanarm-or-brms-mac-catalina/18511/1 "2020-10-08T13:13:26Z")

</div>

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:

- `xcode-select --install`  
Returns:` xcode-select: error: command line tools are already installed, use "Software Update" to install updates`

- Clang++ installed. in R `> Sys.which("clang++")` returns  
` clang++ "/usr/bin/clang++"`

- toolchain installed already [https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-a-Mac#prerequisite--c-toolchain-and-configuration](https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-a-Mac#prerequisite--c-toolchain-and-configuration)

- Rcpp installed already

# The errors:

## Simple brms

```no-highlight
datate = data.frame( a = rnorm(100, 1), b = c(rep(0, 50), rep(1, 50)))
library(brms)
brm(bf(a~b), datate, cores = 1, chains = 4)

```

returns:

> 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

```no-highlight
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

locale:
[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 

```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 8, 2020, 1:22pm UTC](https://discourse.mc-stan.org/t/unable-to-complete-rstan-installation-run-either-rstanarm-or-brms-mac-catalina/18511/2 "2020-10-08T13:22:49Z")

</div>

> [@pmavros](#):
>
> R 3.6.3 (downgraded from 4.0 because it was not working)

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?

---

<div class="post-metadata">

**Author:** ![pmavros](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@pmavros](https://discourse.mc-stan.org/u/pmavros)\
**Post date:** [October 8, 2020, 1:37pm UTC](https://discourse.mc-stan.org/t/unable-to-complete-rstan-installation-run-either-rstanarm-or-brms-mac-catalina/18511/3 "2020-10-08T13:37:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pmavros](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@pmavros](https://discourse.mc-stan.org/u/pmavros)\
**Post date:** [October 8, 2020, 1:48pm UTC](https://discourse.mc-stan.org/t/unable-to-complete-rstan-installation-run-either-rstanarm-or-brms-mac-catalina/18511/4 "2020-10-08T13:48:47Z")

</div>

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!
