Trouble finding Eigen.hpp

I use “stan(file = “stan_file.stan”, data = stan_data)” to fit my model, and get below error message:

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

But I can find these files, I try to unistall R and Rstudio and reinstall them, I tried R 3.6.1 and R 3.6.3, it does not work.

1 Like

Welcome! Can you tell us what operating system you are on and what version. Also what version of rstan?


1 Like


I had this exact problem yesterday after doing a fresh R, rtools and rstan install on a new windows machine. The issue for me (and I suspect it’s the same here) is that I had R installed in Program Files:


This part of the error message was the same for me, led me to guess g++ it was looking for something like:

C:/Program Files/R/R-3.6.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp

The work-around that worked for me was to reinstall R into a directory without a ’ ’ in the name.


1 Like

This was an issue with the StanHeaders version getting ahead of the RStan version on CRAN, since some of the file paths changed between the two versions. It’s since been reverted but CRAN is still providing the 2.21 binaries. To fix this you need to reinstall the packages from source:


If you can’t install packages from source on your system, you can also manually specify the StanHeaders version to install:

install_version("StanHeaders", version = "2.19.0", repos = "")

Or do