Rstan not compiling on windows. Please help!

Solved by using comments on this thread - Error installing rstan

Hello, I am a complete beginner with R. I only decided to use it in order to do Richard McElreath’s very interesting book Statistical Rethinking, which has it’s own R package that needs RStan to work. But all my attempts to compile RStan on my windows machine have failed so far. I have tried using different versions of R - 4.3.1, 4.1.3, 4.0.5 to see if it’s an old/new issue. But invariably I always get the same error:

cc1plus.exe: out of memory allocating 65536 bytes
make: *** [C:/PROGRA~1/R/R-41~1.0/etc/i386/Makeconf:245: grammar_inst.o] Error 1
ERROR: compilation failed for package 'rstan'
* removing 'C:/Users/91988/Documents/R/win-library/4.1/rstan'
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'C:\Users\91988\Documents/.R/Makevars': No such file or directory
  • Output of devtools::session_info("rstan")
Error in loadNamespace(x) : there is no package called ‘devtools’

Kindly help.

The alternative is to use it on Linux, but my main work happens entirely on windows. Rebooting each time is only likely to bring down momentum. Any advice will be appreciated. Thanks again.

Can you try the preview version:

# run the next line if you already have rstan installed
# remove.packages(c("StanHeaders", "rstan"))

install.packages("rstan", repos = c("", getOption("repos")))
1 Like