Rstan compile issues after updating to R 4.0.3

Hello Everyone. I have upgraded R version to R.0.3 and rstan compilation keeps giving me the error. Note, that I have tried all the steps given in: R 4.0, rstan, and you , I have updated all the supporting packages. Deleted older versions of rtools and installed Rtools40. I get two error messages when trying to compile stan file:

1)  Error in open.connection(con, open = mode) : 
  Could not resolve host: github.com
In addition: Warning messages:
  1: In readLines(file, warn = TRUE) :
  incomplete final line found on 'F:\1191\eterin\OrderingIV\mtsmtrmiv.stan'
2: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/rtools40/usr/mingw_/bin/g++' not found

2) Error in compileCode(f, code, language = language, verbose = verbose) : 
  cc1plus.exe: fatal error: \Balder/users/eterin/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** [C:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf:229: fileb14475603c26.o] Error 1
Error in sink(type = "output") : invalid connection

Is there anything else I can do except deleting old makevar.win files or renaming and updating stan and stanheaders? I would greatly appreciate your help.

The first error message:

1)  Error in open.connection(con, open = mode) : 
  Could not resolve host: github.com

Is caused by rstan trying to connect to github to check your model against the new version of the compiler. The easiest fix here is to install the preview of the next rstan version which doesn’t make this check:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

As for the second error:

2) Error in compileCode(f, code, language = language, verbose = verbose) : 
  cc1plus.exe: fatal error: \Balder/users/eterin/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directorycompilation terminated.make: *** [C:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf:229: fileb14475603c26.o] Error 1

This happens when your R packages are installed to a directory on a networked drive, rather than locally installed to your computer. R can have difficulties in finding the necessary files during model compilation when this is the case.

If you still have the error after upgrading to the rstan preview, you will need to move your R package directory to a local directory on your computer. If you’re not sure how to do that, I put together an example/guide in this post: 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

1 Like