Compilation ERROR, function(s)/method(s) not created!

Short summary of the problem:
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
cc1plus.exe: fatal error: \ad.uky.edu/AS/Statistics/pch276/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.3/etc/x64/Makeconf:245: file2944ed26ff0.o] Error 1

Here is the code I am trying to run:

example(stan_model, package = "rstan", run.dontrun = TRUE)

If your question relates to installation please provide the following information:

  • Operating System
    Windows 10
  • RStan Version
    2.21.5
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
    Error in file(con, “r”) : cannot open the connection
    In addition: Warning message:
    In file(con, “r”) :
    cannot open file ‘//ad.uky.edu/AS/Statistics/pch276/Documents/.R/Makevars’: No such file or directory
  • Output of devtools::session_info("rstan")
  • Session info -----------------------------------------------------------------
    setting value
    version R version 4.1.3 (2022-03-10)
    os Windows 10 x64 (build 19041)
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate English_United States.1252
    ctype English_United States.1252
    tz America/New_York
    date 2022-04-29
    rstudio 2022.02.0+443 Prairie Trillium (desktop)
    pandoc 2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)

  • Packages ---------------------------------------------------------------------
    ! package * version date (UTC) lib source
    backports 1.2.1 2020-12-09 [1] CRAN (R 4.1.1)
    BH 1.78.0-0 2021-12-15 [1] CRAN (R 4.1.2)
    callr 3.7.0 2021-04-20 [1] CRAN (R 4.1.3)
    checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.1.3)
    cli 3.2.0 2022-02-14 [1] CRAN (R 4.1.3)
    colorspace 2.0-2 2021-06-24 [1] CRAN (R 4.1.1)
    crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.1)
    desc 1.4.1 2022-03-06 [1] CRAN (R 4.1.3)
    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.1)
    fansi 0.5.0 2021-05-25 [1] CRAN (R 4.1.1)
    farver 2.1.0 2021-02-28 [1] CRAN (R 4.1.1)
    ggplot2 * 3.3.5 2021-06-25 [1] CRAN (R 4.1.1)
    glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.3)
    gridExtra 2.3 2017-09-09 [1] CRAN (R 4.1.2)
    gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.1)
    inline 0.3.19 2021-05-31 [1] CRAN (R 4.1.3)
    isoband 0.2.5 2021-07-13 [1] CRAN (R 4.1.1)
    labeling 0.4.2 2020-10-20 [1] CRAN (R 4.1.0)
    lattice 0.20-45 2021-09-22 [2] CRAN (R 4.1.3)
    lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.1)
    loo 2.5.1 2022-03-24 [1] CRAN (R 4.1.3)
    magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0)
    MASS 7.3-55 2022-01-16 [2] CRAN (R 4.1.3)
    Matrix 1.4-0 2021-12-08 [2] CRAN (R 4.1.3)
    matrixStats 0.60.1 2021-08-23 [1] CRAN (R 4.1.1)
    mgcv 1.8-39 2022-02-24 [2] CRAN (R 4.1.3)
    munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.1)
    nlme 3.1-155 2022-01-16 [2] CRAN (R 4.1.3)
    pillar 1.6.2 2021-07-29 [1] CRAN (R 4.1.1)
    pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.1.3)
    pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.1)
    prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.1)
    processx 3.5.3 2022-03-25 [1] CRAN (R 4.1.3)
    ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.3)
    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.1)
    RcppEigen 0.3.3.9.1 2020-12-17 [1] CRAN (R 4.1.0)
    D RcppParallel 5.1.5 2022-01-05 [1] CRAN (R 4.1.3)
    rlang 1.0.2 2022-03-04 [1] CRAN (R 4.1.3)
    rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.1)
    rstan * 2.21.5 2022-04-11 [1] CRAN (R 4.1.3)
    scales 1.1.1 2020-05-11 [1] CRAN (R 4.1.1)
    StanHeaders * 2.21.0-7 2020-12-17 [1] CRAN (R 4.1.3)
    tibble 3.1.4 2021-08-25 [1] CRAN (R 4.1.1)
    utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.1)
    vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.1)
    viridisLite 0.4.0 2021-04-13 [1] CRAN (R 4.1.1)
    withr 2.2.0 2020-04-20 [1] CRAN (R 4.1.3)

[1] \ad.uky.edu/AS/Statistics/pch276/Documents/R/win-library/4.1
[2] C:/Program Files/R/R-4.1.3/library

D – DLL MD5 mismatch, broken installation.


Is there anyone able to help me to solve the problem. By the way, I have uninstall and install the rstan and StanHeaders a lot of times.

Thank you very much.

This error is occurring because your R packages are installed on a network drive: \ad.uky.edu/AS/Statistics/pch276/Documents/R/win-library, rather than on your local computer. R can have trouble finding headers from packages during compilation when this is the case.

To resolve this, you’ll need to move your R package library to your local computer

writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”)))
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:/Program Files/.R/Makevars’: No such file or directory

It still happens. Could you please resolve this please?

This command (I’m guessing from the forum post template?) is only for showing the contents of the Makevars file. On Windows, this file is called ‘Makevars.win’.

The process for creating it is covered in the Getting Started Guide here: Configuring C Toolchain for Windows · stan-dev/rstan Wiki · GitHub