Help Needed - Error when compiling stancode

Hi,

I am getting an error as below when trying to compile stan code. I can however see the Eigen.hpp file in that path. Does anyone know why is this happening? I have tried both RStudio and R console directly, but same error.

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
cc1plus.exe: fatal error: …/R/R-4.1.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** […/R/R-4.1.1/etc/x64/Makeconf:245: file4ff05ac045af.o] Error 1

Thanks in advance

Can you post the output from:

devtools::session_info("rstan")

The output is as below:

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

  • Packages --------------------------------------------------------------------------------------------------------------------
    ! package * version date lib source
    backports 1.2.1 2020-12-09 [1] CRAN (R 4.1.1)
    BH 1.75.0-0 2021-01-11 [1] CRAN (R 4.1.1)
    callr 3.7.0 2021-04-20 [1] CRAN (R 4.1.1)
    checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.1.1)
    cli 3.0.1 2021-07-17 [1] CRAN (R 4.1.1)
    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)
    curl 4.3.2 2021-06-23 [1] CRAN (R 4.1.1)
    desc 1.3.0 2021-03-05 [1] CRAN (R 4.1.1)
    digest 0.6.27 2020-10-24 [1] CRAN (R 4.1.1)
    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.4.2 2020-08-27 [1] CRAN (R 4.1.1)
    gridExtra 2.3 2017-09-09 [1] CRAN (R 4.1.1)
    gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.1)
    inline 0.3.15 2021-09-15 [1] local
    isoband 0.2.5 2021-07-13 [1] CRAN (R 4.1.1)
    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.1)
    lattice 0.20-44 2021-05-02 [1] CRAN (R 4.1.1)
    lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.1)
    loo 2.4.1 2020-12-09 [1] CRAN (R 4.1.1)
    magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.1)
    MASS 7.3-54 2021-05-03 [1] CRAN (R 4.1.1)
    Matrix 1.3-4 2021-06-01 [1] 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 [1] CRAN (R 4.1.1)
    munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.1)
    nlme 3.1-152 2021-02-04 [1] CRAN (R 4.1.1)
    pillar 1.6.2 2021-07-29 [1] CRAN (R 4.1.1)
    pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.1.1)
    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.2 2021-04-30 [1] CRAN (R 4.1.1)
    ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.1)
    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.1)
    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.1)
    D RcppParallel 5.1.4 2021-05-04 [1] CRAN (R 4.1.1)
    rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.1)
    rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.1)
    rstan * 2.21.2 2020-07-27 [1] CRAN (R 4.1.1)
    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.1)
    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)
    V8 3.4.2 2021-05-01 [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.4.2 2021-04-18 [1] CRAN (R 4.1.1)

[1] …/R/R-4.1.1/library

D – DLL MD5 mismatch, broken installation.

I also wanted to add that i have tried reinstalling StanHeaders package, and i have noticed that there maybe an issue with the UNC path. I see the below message, maybe i need to somehow direct R to install the package in C\Users\ga instead? If so, how do i do it?
‘\fnyipw01\HOB_FID_Home\ga’
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.

Ah yes, this is likely to be the issue: \fnyipw01\HOB_FID_Home\ga

That indicates that your R package library is located on a network drive, not somewhere locally on your computer. When this is the case, R can have troubles loading compilation dependencies from installed packages.

To resolve this, you need to move your package library to somewhere on your local computer. If you’re not sure how to do this, I wrote some instructions in a previous post, you’ll just need to change the target directory: 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

I did a clean install of R in C: drive, where I have full admin rights and now I am able to compile. I will review the previous post that you pointed out above and see if that solves my issue.

Thanks!