# BRMS compilation error when using rstan (Windows 10)

**URL:** <https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099>\
**Category:** brms\
**Created:** [April 5, 2020, 12:42pm UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099 "2020-04-05T12:42:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oberauer](https://avatars.discourse-cdn.com/v4/letter/o/ed655f/32.png) [@Oberauer](https://discourse.mc-stan.org/u/Oberauer)\
**Post date:** [April 5, 2020, 12:42pm UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/1 "2020-04-05T12:42:32Z")

</div>

I’m running Windows 10, R version 3.6.3, brms version 2.12.0 and rstan version 2.19.3.  
Running a simple brms model such as

fit \<- brm(count ~ zAge + zBase \* Trt + (1|patient),  
data = epilepsy, family = poisson())

shortly after starting compilation, I get the error message:

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Oberauer/Documents/R/win-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory  
g++.exe: error: Oberauer/Documents/R/win-library/3.6/StanHeaders/include: No such file or directory  
g++.exe: error: Oberauer/Documents/R/win-library/3.6/RcppEigen/include: No such file or directory  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf:215: file632c4d56612d.o] Error 1

When I don’t use rstan, everything runs fine.

---

<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:** [April 5, 2020, 4:57pm UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/2 "2020-04-05T16:57:13Z")

</div>

You need to run

> [@Installing RStan (and StanHeaders) on Windows ATM](https://discourse.mc-stan.org/t/installing-rstan-and-stanheaders-on-windows-atm/13132/2):
>
> Now do install.packages("rstan", type = "win.binary", dependencies = TRUE) install.packages( "https://win-builder.r-project.org/9256KcZ01L9C/StanHeaders\_2.19.2.zip", repos = NULL, type = "win.binary")

---

<div class="post-metadata">

**Author:** ![Oberauer](https://avatars.discourse-cdn.com/v4/letter/o/ed655f/32.png) [@Oberauer](https://discourse.mc-stan.org/u/Oberauer)\
**Post date:** [April 27, 2020, 9:36am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/3 "2020-04-27T09:36:04Z")

</div>

Thank you for the response. The second install.packages does not work because the URL does not exist.

---

<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:** [April 27, 2020, 5:32pm UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/4 "2020-04-27T17:32:15Z")

</div>

It would be better to upgrade to R 4.0 but otherwise, try the updated link again:

> [@Installing RStan (and StanHeaders) on Windows ATM](https://discourse.mc-stan.org/t/installing-rstan-and-stanheaders-on-windows-atm/13132/3):
>
> Now do install.packages("rstan", type = "win.binary", dependencies = TRUE) install.packages( "https://win-builder.r-project.org/aRC5uk2E56sw/StanHeaders\_2.19.2.zip", repos = NULL, type = "win.binary")

---

<div class="post-metadata">

**Author:** ![Simon\_vB](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/simon_vb/32/12135_2.png) [@Simon\_vB](https://discourse.mc-stan.org/u/Simon_vB)\
**Post date:** [July 4, 2021, 3:20am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/5 "2021-07-04T03:20:46Z")

</div>

Unfortunately I have a similar problem, but these solutions do not work for me. My error also specifies that Eigen.hpp file is not present in StanHeaders 2.21.0. Does anybody know about any fixes?

---

<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:** [July 9, 2021, 9:57am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/6 "2021-07-09T09:57:48Z")

</div>

What do you get from:

```r
devtools::session_info("rstan")

```

---

<div class="post-metadata">

**Author:** ![Simon\_vB](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/simon_vb/32/12135_2.png) [@Simon\_vB](https://discourse.mc-stan.org/u/Simon_vB)\
**Post date:** [August 18, 2021, 4:15am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/7 "2021-08-18T04:15:42Z")

</div>

Sorry for the late reply. Strangely, I can run rstanarm, but not brms. I see something strange happening with the MD5 statement at the bottom and I’ve tried reinstalling RcppParallel which was suggested in another thread, but that did not resolve it. Here is the output:

- Session info --------------------------------------------------------------------  
setting value  
version R version 4.0.5 (2021-03-31)  
os Windows 10 x64  
system x86\_64, mingw32  
ui RStudio  
language (EN)  
collate English\_Australia.1252  
ctype English\_Australia.1252  
tz Australia/Sydney  
date 2021-08-18

- Packages ------------------------------------------------------------------------  
! package \* version date lib source  
assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.3)  
backports 1.2.1 2020-12-09 [2] CRAN (R 4.0.3)  
BH 1.75.0-0 2021-01-11 [2] CRAN (R 4.0.3)  
callr 3.7.0 2021-04-20 [1] CRAN (R 4.0.5)  
checkmate 2.0.0 2020-02-06 [2] CRAN (R 4.0.3)  
cli 2.3.1 2021-02-23 [2] CRAN (R 4.0.4)  
colorspace 2.0-2 2021-06-24 [1] CRAN (R 4.0.5)  
crayon 1.4.1 2021-02-08 [2] CRAN (R 4.0.4)  
curl 4.3.2 2021-06-23 [1] CRAN (R 4.0.5)  
desc 1.3.0 2021-03-05 [2] CRAN (R 4.0.4)  
digest 0.6.27 2020-10-24 [2] CRAN (R 4.0.3)  
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.5)  
fansi 0.5.0 2021-05-25 [1] CRAN (R 4.0.5)  
farver 2.1.0 2021-02-28 [2] CRAN (R 4.0.4)  
ggplot2 \* 3.3.3 2020-12-30 [2] CRAN (R 4.0.3)  
glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.3)  
gridExtra 2.3 2017-09-09 [2] CRAN (R 4.0.3)  
gtable 0.3.0 2019-03-25 [2] CRAN (R 4.0.3)  
inline 0.3.19 2021-05-31 [1] CRAN (R 4.0.5)  
isoband 0.2.4 2021-03-03 [2] CRAN (R 4.0.4)  
jsonlite 1.7.2 2020-12-09 [2] CRAN (R 4.0.3)  
labeling 0.4.2 2020-10-20 [2] CRAN (R 4.0.3)  
lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.5)  
lifecycle 1.0.0 2021-02-15 [2] CRAN (R 4.0.4)  
loo 2.4.1 2020-12-09 [2] CRAN (R 4.0.3)  
magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.0.3)  
MASS 7.3-53.1 2021-02-12 [2] CRAN (R 4.0.5)  
Matrix \* 1.3-2 2021-01-06 [2] CRAN (R 4.0.5)  
matrixStats 0.59.0 2021-06-01 [1] CRAN (R 4.0.5)  
mgcv 1.8-34 2021-02-16 [2] CRAN (R 4.0.5)  
munsell 0.5.0 2018-06-12 [2] CRAN (R 4.0.3)  
nlme 3.1-152 2021-02-04 [2] CRAN (R 4.0.5)  
pillar 1.6.1 2021-05-16 [1] CRAN (R 4.0.5)  
pkgbuild 1.2.0 2020-12-15 [2] CRAN (R 4.0.3)  
pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.3)  
prettyunits 1.1.1 2020-01-24 [2] CRAN (R 4.0.3)  
processx 3.5.2 2021-04-30 [1] CRAN (R 4.0.5)  
ps 1.6.0 2021-02-28 [2] CRAN (R 4.0.4)  
R6 2.5.0 2020-10-28 [2] CRAN (R 4.0.3)  
RColorBrewer 1.1-2 2014-12-07 [2] CRAN (R 4.0.3)  
Rcpp \* 1.0.6 2021-01-15 [1] CRAN (R 4.0.5)  
RcppEigen 0.3.3.9.1 2020-12-17 [1] CRAN (R 4.0.5)  
D RcppParallel 5.1.4 2021-05-04 [1] CRAN (R 4.0.5)  
rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.5)  
rprojroot 2.0.2 2020-11-15 [2] CRAN (R 4.0.3)  
rstan \* 2.21.2 2020-07-27 [1] CRAN (R 4.0.5)  
scales 1.1.1 2020-05-11 [2] CRAN (R 4.0.3)  
StanHeaders \* 2.21.0-7 2020-12-17 [1] CRAN (R 4.0.5)  
tibble \* 3.0.5 2021-01-15 [2] CRAN (R 4.0.3)  
utf8 1.2.1 2021-03-12 [2] CRAN (R 4.0.4)  
V8 3.4.2 2021-05-01 [1] CRAN (R 4.0.5)  
vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.5)  
viridisLite 0.4.0 2021-04-13 [1] CRAN (R 4.0.5)  
withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.5)

[1] Masked institutional account library  
[2] C:/Program Files/R/R-4.0.5/library

D – DLL MD5 mismatch, broken installation.

---

<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:** [August 18, 2021, 9:19am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/8 "2021-08-18T09:19:34Z")

</div>

Where it says:  
`[1] Masked institutional account library`

Is that on a shared network drive? It would say something like `/server/username/R` instead of `C:/Users/username/R`

---

<div class="post-metadata">

**Author:** ![Simon\_vB](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/simon_vb/32/12135_2.png) [@Simon\_vB](https://discourse.mc-stan.org/u/Simon_vB)\
**Post date:** [August 19, 2021, 2:14am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/9 "2021-08-19T02:14:07Z")

</div>

Yes that’s a shared network drive. Could that be where the problem stems from?

---

<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:** [August 19, 2021, 2:24am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/10 "2021-08-19T02:24:51Z")

</div>

Yep, R can have trouble finding dependencies during compilation when the libraries are installed on a network drive. This doesn’t affect rstanarm because the models are all pre-compiled.

There are two options here, the first thing to try would be to use brms with the cmdstanr backend:

Install cmdstanr and cmdstan using [the instructions here](https://mc-stan.org/cmdstanr/articles/cmdstanr.html) and call brms with `backend="cmdstanr"`

cmdstanr uses a different approach for including the dependencies so may avoid the issue.

If that doesn’t work, then you’ll need to move your R package library to somewhere on your local drive

---

<div class="post-metadata">

**Author:** ![Simon\_vB](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/simon_vb/32/12135_2.png) [@Simon\_vB](https://discourse.mc-stan.org/u/Simon_vB)\
**Post date:** [August 19, 2021, 6:50am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/11 "2021-08-19T06:50:53Z")

</div>

Thank you for your help. It didn’t work, and unfortunately my library keeps switching back to the network drive, but I’ll try some more different ways to change it.

---

<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:** [August 19, 2021, 6:54am UTC](https://discourse.mc-stan.org/t/brms-compilation-error-when-using-rstan-windows-10/14099/12 "2021-08-19T06:54:40Z")

</div>

I wrote up some instructions for changing the library over in [this post](https://discourse.mc-stan.org/t/modeling-failed-warnings-c-users-r-34-1-3-rtools40-usr-mingw-bin-g-not-found-errors-multiple-results-for-cxx14flags-found-something-is-wrong-false/19154/54), if that helps
