Trouble installing rstan on macOS Catalina, R version 4.0.3

@andrjohns

Operating System: macOS Catalina
Interface Version: current CRAN version
Compiler/Toolkit: https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Mac

After a hiatus, I came back to modeling in R and Rstan and opted to start out by updating my version of R (I had a pre-4 version previously).

The Toolchain installer seemed to work well. Next, I was surprised that the compiler optimizations gave some errors, but I forged ahead.

When running the example model, meanwhile, it was clear that the Rstan library was loaded, but the interface just hung there indefinitely (saying that the model code was successfully parsed and translated into C++ code).

Reading the forum, it sounds like some holdovers from the previous installation might be causing some of the issues, but I’m not sure what to try next (?). For system information, please see below:

> Sys.getenv("PATH")
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
> Sys.getenv("BINPREF")
[1] ""
> readLines("~/.Rprofile")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/Users/jeremykoster/.Rprofile': No such file or directory
> readLines("~/.Renviron")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/Users/jeremykoster/.Renviron': No such file or directory
> devtools::session_info("rstan")
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.3 (2020-10-10)
 os       macOS Catalina 10.15.4      
 system   x86_64, darwin17.0          
 ui       AQUA                        
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2020-12-23                  

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────
 package      * version   date       lib source        
 assertthat     0.2.1     2019-03-21 [1] CRAN (R 4.0.2)
 backports      1.2.1     2020-12-09 [1] CRAN (R 4.0.2)
 BH             1.72.0-3  2020-01-08 [1] CRAN (R 4.0.2)
 brio           1.1.0     2020-08-31 [1] CRAN (R 4.0.2)
 callr          3.5.1     2020-10-13 [1] CRAN (R 4.0.2)
 checkmate      2.0.0     2020-02-06 [1] CRAN (R 4.0.2)
 cli            2.2.0     2020-11-20 [1] CRAN (R 4.0.2)
 colorspace     2.0-0     2020-11-11 [1] CRAN (R 4.0.2)
 crayon         1.3.4     2017-09-16 [1] CRAN (R 4.0.2)
 curl           4.3       2019-12-02 [1] CRAN (R 4.0.1)
 desc           1.2.0     2018-05-01 [1] CRAN (R 4.0.2)
 diffobj        0.3.2     2020-10-05 [1] CRAN (R 4.0.2)
 digest         0.6.27    2020-10-24 [1] CRAN (R 4.0.2)
 ellipsis       0.3.1     2020-05-15 [1] CRAN (R 4.0.2)
 evaluate       0.14      2019-05-28 [1] CRAN (R 4.0.1)
 fansi          0.4.1     2020-01-08 [1] CRAN (R 4.0.2)
 farver         2.0.3     2020-01-16 [1] CRAN (R 4.0.2)
 ggplot2        3.3.2     2020-06-19 [1] CRAN (R 4.0.2)
 glue           1.4.2     2020-08-27 [1] CRAN (R 4.0.2)
 gridExtra      2.3       2017-09-09 [1] CRAN (R 4.0.2)
 gtable         0.3.0     2019-03-25 [1] CRAN (R 4.0.2)
 inline         0.3.17    2020-12-01 [1] CRAN (R 4.0.2)
 isoband        0.2.3     2020-12-01 [1] CRAN (R 4.0.2)
 jsonlite       1.7.2     2020-12-09 [1] CRAN (R 4.0.2)
 labeling       0.4.2     2020-10-20 [1] CRAN (R 4.0.2)
 lattice        0.20-41   2020-04-02 [1] CRAN (R 4.0.3)
 lifecycle      0.2.0     2020-03-06 [1] CRAN (R 4.0.2)
 loo            2.4.1     2020-12-09 [1] CRAN (R 4.0.2)
 magrittr       2.0.1     2020-11-17 [1] CRAN (R 4.0.2)
 MASS           7.3-53    2020-09-09 [1] CRAN (R 4.0.3)
 Matrix         1.2-18    2019-11-27 [1] CRAN (R 4.0.3)
 matrixStats    0.57.0    2020-09-25 [1] CRAN (R 4.0.2)
 mgcv           1.8-33    2020-08-27 [1] CRAN (R 4.0.3)
 munsell        0.5.0     2018-06-12 [1] CRAN (R 4.0.2)
 nlme           3.1-149   2020-08-23 [1] CRAN (R 4.0.3)
 pillar         1.4.7     2020-11-20 [1] CRAN (R 4.0.2)
 pkgbuild       1.2.0     2020-12-15 [1] CRAN (R 4.0.2)
 pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.0.2)
 pkgload        1.1.0     2020-05-29 [1] CRAN (R 4.0.2)
 praise         1.0.0     2015-08-11 [1] CRAN (R 4.0.2)
 prettyunits    1.1.1     2020-01-24 [1] CRAN (R 4.0.2)
 processx       3.4.5     2020-11-30 [1] CRAN (R 4.0.2)
 ps             1.5.0     2020-12-05 [1] CRAN (R 4.0.2)
 R6             2.5.0     2020-10-28 [1] CRAN (R 4.0.2)
 RColorBrewer   1.1-2     2014-12-07 [1] CRAN (R 4.0.2)
 Rcpp           1.0.5     2020-07-06 [1] CRAN (R 4.0.2)
 RcppEigen      0.3.3.9.1 2020-12-17 [1] CRAN (R 4.0.2)
 RcppParallel   5.0.2     2020-06-24 [1] CRAN (R 4.0.2)
 rematch2       2.1.2     2020-05-01 [1] CRAN (R 4.0.2)
 rlang          0.4.9     2020-11-26 [1] CRAN (R 4.0.2)
 rprojroot      2.0.2     2020-11-15 [1] CRAN (R 4.0.2)
 rstan          2.21.2    2020-07-27 [1] CRAN (R 4.0.3)
 rstudioapi     0.13      2020-11-12 [1] CRAN (R 4.0.2)
 scales         1.1.1     2020-05-11 [1] CRAN (R 4.0.2)
 StanHeaders    2.21.0-7  2020-12-17 [1] CRAN (R 4.0.2)
 testthat       3.0.1     2020-12-17 [1] CRAN (R 4.0.2)
 tibble         3.0.4     2020-10-12 [1] CRAN (R 4.0.2)
 utf8           1.1.4     2018-05-24 [1] CRAN (R 4.0.2)
 V8             3.4.0     2020-11-04 [1] CRAN (R 4.0.2)
 vctrs          0.3.6     2020-12-17 [1] CRAN (R 4.0.2)
 viridisLite    0.3.0     2018-02-01 [1] CRAN (R 4.0.1)
 waldo          0.2.3     2020-11-09 [1] CRAN (R 4.0.2)
 withr          2.3.0     2020-09-22 [1] CRAN (R 4.0.2)

[1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

Hi, did you remove ~/.R/Makevars?

1 Like

Thanks, @torkar.

I’m seeing five Makevars text files in my libraries (some are in rstantools and some are in Rcpp-related folders). I went through and deleted all of the Makevars files associated with the older version of R (I had 3.6 before upgrading recently). This leaves only the Makevars files associated with R version 4.0.3.

The example model still doesn’t estimate, however:
example(stan_model, package = "rstan", run.dontrun = TRUE)

Should I delete the version 4.0 Makevars files as well?

Hi

Remove the final Makevars file and restart RStudio.

1 Like

Thanks, @torkar.

As an update, I removed the Makevars files and then started up RStudio again. This was a change for me because I had been running the example model in R. In this case, it works fine in RStudio (and other Stan models also compile and estimate in RStudio, too).

However, neither the example model nor any other model I try to fit works in base R. I’m trying to figure out why that would be the case. Working in RStudio is fine for now, but in the long term it would be ideal to have the option of working in R, too.

Hmmm funky… what happens when you run it in R? Can you paste the whole error msg?

Frankly, it just hangs with this message:

TRANSLATING MODEL '16a540c6086086816528e4524def24d9' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '16a540c6086086816528e4524def24d9'.

I’ve waited up to ten minutes before killing it. I’ll let it go longer this time.

If you first compile the model and then sample where does it hang?

The message above is what happens when I try to run the example model script:

example(stan_model, package = "rstan", run.dontrun = TRUE)

By contrast, if I run another model from previous research, it just hangs with no messages. Normally I would expect a web browser to open with updates on the progress of the chains. So far, though, there’s nothing to see when using base R. (This same model compiles and does fine in RStudio.)

But you can select to only compile first. Then you select to only sample. I’m not on the laptop but these are two different functions in Stan.

Hang on. Now I’m getting new errors in RStudio as well:

sh: -c: line 0: unexpected EOF while looking for matching `β€˜β€™
sh: -c: line 1: syntax error: unexpected end of file

And it seems I’m not the only running into this: Weird error in R studio console whenever I open up a stan file

1 Like