Errors compiling Stan Program when trying to run brms model

My first post here because it’s 1am and I’m pulling my hair out… Earlier today I was quite happily fitting my brms models no problems whatsoever. I had a couple of specific ordered beta regression models to run and remembered that @saudiwin the package creator for ordbetareg had added an argument to specify the true bounds for the data if they aren’t in the dataset themselves necessarily. So I went to install the development version and after that things started going weird.

I’ve tried completely (like completely completely) uninstalling R, RStudio, and Rtools along with any folders or files kicking about, and at various stages have had different errors. But currently I am finding I get the following anytime I try to run a model with brms:

Compiling Stan program...
make cmd is
  make -f "C:/PROGRA~1/R/R-42~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-42~1.1/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file4a28769e268b.dll" WIN=64 TCLBIN= OBJECTS="file4a28769e268b.o"

make would use
Warning message:
In system(paste(cmd, "-n")) : 'make' not found
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Warning message:In system(cmd) : 'make' not found
Error in sink(type = "output") : invalid connection

My Rstan session info is

> devtools::session_info("rstan")
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.1 (2022-06-23 ucrt)
 os       Windows 10 x64 (build 19044)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United Kingdom.utf8
 ctype    English_United Kingdom.utf8
 tz       Europe/London
 date     2022-08-17
 rstudio  2022.07.1+554 Spotted Wakerobin (desktop)
 pandoc   NA

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package      * version   date (UTC) lib source
   backports      1.4.1     2021-12-13 [1] CRAN (R 4.2.0)
   BH             1.78.0-0  2021-12-15 [1] CRAN (R 4.2.0)
   callr          3.7.1     2022-07-13 [1] CRAN (R 4.2.1)
   checkmate      2.1.0     2022-04-21 [1] CRAN (R 4.2.1)
   cli            3.3.0     2022-04-25 [1] CRAN (R 4.2.1)
   colorspace     2.0-3     2022-02-21 [1] CRAN (R 4.2.1)
   crayon         1.5.1     2022-03-26 [1] CRAN (R 4.2.1)
   desc           1.4.1     2022-03-06 [1] CRAN (R 4.2.1)
   digest         0.6.29    2021-12-01 [1] CRAN (R 4.2.1)
   fansi          1.0.3     2022-03-24 [1] CRAN (R 4.2.1)
   farver         2.1.1     2022-07-06 [1] CRAN (R 4.2.1)
   ggplot2      * 3.3.6     2022-05-03 [1] CRAN (R 4.2.1)
   glue           1.6.2     2022-02-24 [1] CRAN (R 4.2.1)
   gridExtra      2.3       2017-09-09 [1] CRAN (R 4.2.1)
   gtable         0.3.0     2019-03-25 [1] CRAN (R 4.2.1)
   inline         0.3.19    2021-05-31 [1] CRAN (R 4.2.1)
   isoband        0.2.5     2021-07-13 [1] CRAN (R 4.2.1)
   labeling       0.4.2     2020-10-20 [1] CRAN (R 4.2.0)
   lattice        0.20-45   2021-09-22 [2] CRAN (R 4.2.1)
   lifecycle      1.0.1     2021-09-24 [1] CRAN (R 4.2.1)
   loo            2.5.1     2022-03-24 [1] CRAN (R 4.2.1)
   magrittr       2.0.3     2022-03-30 [1] CRAN (R 4.2.1)
   MASS           7.3-57    2022-04-22 [2] CRAN (R 4.2.1)
   Matrix         1.4-1     2022-03-23 [2] CRAN (R 4.2.1)
   matrixStats    0.62.0    2022-04-19 [1] CRAN (R 4.2.1)
   mgcv           1.8-40    2022-03-29 [2] CRAN (R 4.2.1)
   munsell        0.5.0     2018-06-12 [1] CRAN (R 4.2.1)
   nlme           3.1-157   2022-03-25 [2] CRAN (R 4.2.1)
   pillar         1.8.0     2022-07-18 [1] CRAN (R 4.2.1)
   pkgbuild       1.3.1     2021-12-20 [1] CRAN (R 4.2.1)
   pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.2.1)
   prettyunits    1.1.1     2020-01-24 [1] CRAN (R 4.2.1)
   processx       3.7.0     2022-07-07 [1] CRAN (R 4.2.1)
   ps             1.7.1     2022-06-18 [1] CRAN (R 4.2.1)
   R6             2.5.1     2021-08-19 [1] CRAN (R 4.2.1)
   RColorBrewer   1.1-3     2022-04-03 [1] CRAN (R 4.2.0)
   Rcpp         * 1.0.9     2022-07-08 [1] CRAN (R 4.2.1)
   RcppEigen      0.3.3.9.2 2022-04-08 [1] CRAN (R 4.2.1)
 D RcppParallel   5.1.5     2022-01-05 [1] CRAN (R 4.2.1)
   rlang          1.0.4     2022-07-12 [1] CRAN (R 4.2.1)
   rprojroot      2.0.3     2022-04-02 [1] CRAN (R 4.2.1)
   rstan        * 2.21.5    2022-04-11 [1] CRAN (R 4.2.1)
   scales         1.2.0     2022-04-13 [1] CRAN (R 4.2.1)
   StanHeaders  * 2.21.0-7  2020-12-17 [1] CRAN (R 4.2.1)
   tibble         3.1.8     2022-07-22 [1] CRAN (R 4.2.1)
   utf8           1.2.2     2021-07-24 [1] CRAN (R 4.2.1)
   vctrs          0.4.1     2022-04-13 [1] CRAN (R 4.2.1)
   viridisLite    0.4.0     2021-04-13 [1] CRAN (R 4.2.1)
   withr          2.5.0     2022-03-03 [1] CRAN (R 4.2.1)

 [1] C:/Users/James/AppData/Local/R/win-library/4.2
 [2] C:/Program Files/R/R-4.2.1/library

 D ── DLL MD5 mismatch, broken installation.

My guess is some dependency updates have caused issues, but I thought the complete reinstall of everything would sort things out.

I’ve tried searching through some threads here but must confess I don’t really know what I am looking for with this issue.

Any help would be really appreciated!

Thanks,

James

Sorry about that. It’s super frustrating not being able to install code. The problem is that it’s never possible to anticipate all contingencies. What happened to your system is that you somehow uninstalled (or never installed) a critical component (see below).

I have two alternative suggestions which don’t directly answer your question:

  • use the Linux subsystem for Windows; Windows isn’t very friendly for C++, but the Linux subsystem works great
  • switch to cmdstanr, which is easier to install and also 2 years more up to date with Stan than rstan on CRAN (and 1 year more up to date than rstan on GitHub).

This is telling you that the make command isn’t found. That’s the system we use to build C++ programs. So we need it to compile Stan programs. It’s included with the RTools download, so you need to go back to that step and verify you have make on your system path.

1 Like

Can you try the steps from the Getting Started guide? Namely reinstall RTools42 and then install the rstan preview

1 Like

Thanks both - I did try reinstalling RTools42 a couple times, but kept having issues. In the end I just backed up things and did a quick factory reset on my PC and then reinstalled everything from scratch in particular following the Getting Started guide again on rstan. All seems to be working now though.

I’ll just clarify for any future readers that a factory reset or system restore is a “nuclear option” that is never necessary for fixing an rstan install, and that we always recommend letting the Stan team help debug the issue through the forum

1 Like

Haha, yea sorry… it was me panicking and needing a quick fix to get going given a deadline on something (that ended up getting cancelled anyway… sods law). In future I’ll be looking to try to understand and actually solve the issue properly. Thanks for the great community here!

1 Like

Feel free to keep asking whatever you’d like on the forums. And I’m very sorry Stan drove you to the nuclear option. This is largely our fault for not having better encapsulated installs. It’s been a thorn in our side since version 1.0, because getting C++ to talk to R is a huge pain.

As @andrjohns says, you should never need to factory reboot the OS or even reinstall R. But we can only respond so fast to messages on the forums. So I understand why you were driven to the reinstall-the-OS option.

I’d like to emphasize that installs are less dependent on R with cmdstanr and should be much easier than with RStan. It’s also more up to date with Stan. The only reason to use RStan at this point is if you want to release a binary-only package or need R-level access to Stan model log densities and gradients.