In your R HOME directory (usually the Documents folder on Windows), you should have a .Rprofile
file (you can check where this is using: file.path(Sys.getenv("HOME"), ".Rprofile")
).
Open up that file with a text editor (like Notepad) and delete the line: Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")
After that, restart R and run:
Sys.which("g++")
If that returns something with C:\\rtools40
at the start, you should be good to go
Hi all,
I had similar error after updating to R4.0. My model no longer run.
Turned out it was enough to remove compiled models and recompile with new RTools.
Hope someone will find this useful.
5 Likes
I had the same issue and had to go into my R library and uninstall Rcpp and reinstall both it and rstan. I’m wondering if I updating packages prior to installing updated rtools was the culprit.
Thanks for all of your help!
2 Likes
Yep, same here, reinstalling both rcpp and rstan did the trick.
1 Like
I cannot solve this issue; I am running R version 4.0.4, Rtools 4.0, Rstudio 1.4.1106, on Windows 10 on a brand new laptop (first time installing R, Rtools, and Rstudio).
I thought that running:
install.packages(c(“Rcpp”, “RcppEigen”, “rstan”), type = “source”)
would do the trick, but Rcpp cannot install because:
error: C:/Users/ac22qawo/Documents/R/R-4.0.4/library/rstan/lib/x64/libStanServices.a: No such file or directory
no DLL was created
Also, running Sys.getenv(“BINPREF”) returns “”, and so does running Sys.which(“g++”).
This all started because when compiling a simple model of the mean to fit a dataset with a few data points, the output was:
Error: cannot allocate vector of size 15842.6 Gb
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Apologies: indeed, by correctly removing Rcpp from my machine, and by recompiling old STAN models, the trick worked!
thank you so much.
this solved my problem.
Having this same issue. When you all talk about “recompiling old STAN models” as a fix for the problem, do you mean rerun all the models which use the STAN script I am trying to run? Just confused about which STAN models rerun exactly.
Any Stan models which were compiled prior to R4.x, with the auto_write=TRUE
setting will have created an .rds
file in the same directory as the stan model with the pre-compiled model. If you delete these .rds
files then the models will be re-compiled under the new RTools
2 Likes