"No such file or directorycompilation terminated.make" in Windows 10

When running example(stan_model, package = "rstan", run.dontrun = TRUE) or any other Stan code, I get the following error:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  cc1plus.exe: fatal error: \file.UNIVERSITY.EDU/home/USERNAME/My Documents/R/win-library/4.1/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** [C:/PROGRA~1/R/R-41~1.1/etc/x64/Makeconf:245: file3eb4a135864.o] Error 1

Other people have had similar issues on old versions of RStan (per a quick forum search): I’ve tried the recommended fix (updating RStan and StanHeaders to the most recent version, simultaneously), to no avail.

I’m running:

  • Windows 10
  • RStan Version 2.21.0
  • I’m also getting “Error: object ‘writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”)))’ not found.” I do have .R/Makevars in my HOME, so I’m not sure what’s up with that.
  • Output of devtools::session_info("rstan"):

`- Session info -----------------------------------------------------------------------------------------------------------------
setting value
version R version 4.1.1 (2021-08-10)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz America/New_York
date 2021-08-26

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

[1] \file.UNIVERSITY.edu/home/USERNAME/My Documents/R/win-library/4.1
[2] C:/Program Files/R/R-4.1.1/library

D – DLL MD5 mismatch, broken installation.`

Thank you!

This error is occurring because your R packages are installed on a network drive (\file.UNIVERSITY.edu/home), rather than somewhere on your local computer. This causes R to have trouble finding compilation dependencies when Stan models are compiled.

To fix this, you need to move your R package library to somewhere on your local computer. If you’re not sure how to do that, I wrote up some example instructions over in this post (but you’ll need to change the destination directory depending on where you have write acess): 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 - #54 by andrjohns