BRMS compilation error when using rstan (Windows 10)

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.

You need to run

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

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

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?

What do you get from:

devtools::session_info("rstan")

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.

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

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

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 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

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.

I wrote up some instructions for changing the library over in this post, if that helps