Rtools re-install every time i try to run

I have been trying to get rstan installed and running. I have followed the instructions here (RStan Getting Started · stan-dev/rstan Wiki · GitHub) as closely as possible.

After following all of the steps, I get to this code point:
example(stan_model, package = “rstan”, run.dontrun = TRUE)

RStudio then says that I need to download additional tools – it wants to install Rtools42 every time. I have downloaded it several times already. I have downloaded several different versions of Rtools, but it seems like it can’t find the download.

Ultimately, the example() code produces errors:
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Error in system(paste(MAKE, p1(paste("-f", shQuote(makefiles))), "compilers"),  :   'make' not foundCalls: <Anonymous> -> .shlib_internal -> systemExecution halted

I am not an expert at all. Just trying to get it to work.

I am using Windows.

I downloaded “rstan” from here:
install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

  • 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\Administrator\Documents/.R/Makevars’: No such file or directory

  • Output of devtools::session_info("rstan"):

devtools::session_info(“rstan”)
Error in loadNamespace(x) : there is no package called ‘devtools’

Appreciate any help anyone can provide!

Sorry this hasn’t been answered. And I’m afraid I’m not an expert on either R or Rstan.

Can you switch to cmdstanr? It’s not on CRAN, but it’s much easier to install and keep up to date with Stan than RStan. Also, if you’re comfortable using the Linux subsystem for Windows, it’s much much easier than working in Windows.

If you need to stick to Rstan for some reason, here are the C toolchain config instructions for Windows:

They’re a bit sketchy, because it’s from R. In particular, there seems to be no instructions for verifying that the install is OK.

My guess is that the C++ toolchain isn’t showing up on your path. You can verify by going to a terminal window and typing something like g++ --version.