# Error when running brm model

**URL:** <https://discourse.mc-stan.org/t/error-when-running-brm-model/27951>\
**Category:** brms\
**Tags:** installation, rstan\
**Created:** [June 24, 2022, 10:37pm UTC](https://discourse.mc-stan.org/t/error-when-running-brm-model/27951 "2022-06-24T22:37:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smcelroy1287](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@smcelroy1287](https://discourse.mc-stan.org/u/smcelroy1287)\
**Post date:** [June 24, 2022, 10:37pm UTC](https://discourse.mc-stan.org/t/error-when-running-brm-model/27951/1 "2022-06-24T22:37:05Z")

</div>

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

```nohighlight

```

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:

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [June 29, 2022, 6:36am UTC](https://discourse.mc-stan.org/t/error-when-running-brm-model/27951/2 "2022-06-29T06:36:06Z")

</div>

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:

```r
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](https://mc-stan.org/cmdstanr/) and run your `brms` models with the `backend = "cmdstanr"` option
