Error when running brm model

I am new to stans and I can’t figure out what this error is telling me when I try and run a brm model.
Version of R: 4.2
Rtools: 4.2

Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: filec9e436765c15.o:filec9e436765c15.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: filec9e436765c15.o:filec9e436765c15.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: filec9e436765c15.o:filec9e436765c15.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: filec9e436765c15.o:filec9e436765c15.cpp:(.text$_ZN3tbb10interface
Error in sink(type = “output”) : invalid connection



I think the error is pointing to something that went wrong with the installation. I am not sure if its from the installation of brms or rtools. Thank you for your help!

  • Operating System: Windows 10
  • brms Version:

This issue is occurring because there are some compatibility issues with the version of rstan currently on CRAN. You can install the preview of the next rstan version using:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

Alternatively, you could install the cmdstanr package and run your brms models with the backend = "cmdstanr" option