Error in rstan installation

I cannot create more replies. but I edited the Makevars.win in .R folder and I get:

Sys.which(“g++”)
g++
“”
readLines("~/.R/Makevars.win")
[1] “”
[2] " CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2"

No just the Makevars.win in the folder:

D:\PG\OneDrive - icx.com\Documents\.R\

Great. Now you should be able to run the installation without error

I could not reply because this forum site does not allow more than 22 replies for a new user (that needs to be reconsidered really by the developers).

The installation failed, the installation went much further than before, but now there is again termination error:

C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:10: fatal error: Eigen/Dense: No such file or directory
#include <Eigen/Dense>
^~~~~~~~~~~~~
compilation terminated.
make: *** [C:/PROGRA~1/R/R-40~1.3/etc/i386/Makeconf:229: sparse_extractors.o] Error 1
ERROR: compilation failed for package ‘rstan’

Did you pause the OneDrive sync before installation?

Also, is this a drive on your local computer or a network drive?

I have two local drives C: and D:
The OneDrive is paused.
The odd thing is that the folder Installation is looking for exist on D: not on C: this is why it cannot find it.

This is where the file resides:
D:\PG\OneDrive - icx.com\Documents\R\win-library\4.0\StanHeaders\include\stan\math\prim\mat\fun\Eigen.hpp

Hmm, I’m not sure why its looking on a different drive. Does StanHeaders install fine?

Can you post the full line that resulted in that error (the line starting with g++)?

Can you also post the outputs from:

Sys.getenv("R_LIBS_USER")
Sys.getenv("PKG_LIBS")
readLines("~/.Renviron")
readLines("~/.R/Makevars.win")

The StanHeaders is in the following director:
C:\Users\GP\OneDrive - icx.com\Documents\R\win-library\4.0\StanHeaders\R

and there are 3 files there:
StanHeaders
StanHeaders.rdb
StanHeaders.rdx

Here is more of the error message:
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path

  • DONE (StanHeaders)
  • installing source package ‘rstan’ …
    ** package ‘rstan’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs

*** arch - i386
“C:/rtools40/mingw32/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.3/include” -DNDEBUG -I”…/inst/include" -I"…/inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I’C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/Rcpp/include’ -I’C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/RcppEigen/include’ -I’C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/BH/include’ -I’C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/StanHeaders/include’ -I’C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/RcppParallel/include’ -DRCPP_PARALLEL_USE_TBB=1 -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -c sparse_extractors.cpp -o sparse_extractors.o
In file included from C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/meta/append_return_type.hpp:4,
from C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/meta.hpp:9,
from C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:4,
from sparse_extractors.cpp:2:
C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:10: fatal error: Eigen/Dense: No such file or directory
#include <Eigen/Dense>
^~~~~~~~~~~~~
compilation terminated.
make: *** [C:/PROGRA~1/R/R-40~1.3/etc/i386/Makeconf:229: sparse_extractors.o] Error 1
ERROR: compilation failed for package ‘rstan’

Here is the output

Sys.getenv(“R_LIBS_USER”)
[1] “C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0
Sys.getenv(“PKG_LIBS”)
[1] “”
readLines("~/.Renviron")
[1] “PATH=”{RTOOLS40_HOME}\\usr\\bin;{PATH}""
readLines("~/.R/Makevars.win")
[1] “”
[2] " CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2"

According to this:

Sys.getenv(“R_LIBS_USER”)
[1] “C:/Users/GP/OneDrive - icx.com/Documents/R/win-library/4.0”

You’re instructing R to look for and install packages into the C:/ drive, not the D:/ drive. Is this something that you’ve set somewhere?

All my system and operating files are on C: so I assume the installation will look for C: to install libraries. But, I direct to OneDrive on D: as this is for my documents and local files.

OneDrive synhronization is directed to D:
but I have static folders in C for system files on C:

any idea what to do?

If you restart R and run Sys.getenv("R_LIBS_USER") again, does it still show the C:/ drive?

I’m not sure how that’s getting set to your C drive, but you can override it by editing your .Renviron file (you can just call file.edit("~/.Renviron") and it will open in RStudio). And add the line:

R_LIBS_USER = "D:/PG/OneDrive - icx.com/Documents/R/win-library/4.0"

Then restart R and check that Sys.getenv("R_LIBS_USER") shows the D:/ drive address