Can't get stan() to run with R 4.0.2 despite hours of messing with Makevars.win

Thank you for your quick reply.

It made me smile when you said "You can see the issue in this line: echo C:/Rtools/mingw_64/bin/g++ -shared" because, of course, I do not have the expertise to see anything meaningful there. I’m very glad you can! :-)

I definitely have RTools4 installed. Did that before, based on https://cran.r-project.org/bin/windows/Rtools/

Here are the outputs of the commands you requested:

> Sys.getenv("PATH")
[1] "
C:\\rtools40\\usr\\bin;
C:\\Program Files\\R\\R-4.0.2\\bin\\x64;
C:\\Rtools\\bin;
C:\\Rtools\\bin;
C:\\Rtools\\mingw_32\\bin;
..."

> Sys.getenv("BINPREF")
[1] "C:/Rtools/mingw_$(WIN)/bin/"

> readLines("~/.R/Makevars.win")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'C:/Users/John/Documents/.R/Makevars.win': No such file or directory

I removed Makevars.win based on advice in New error: cleanup_makevar(old) : argument "RMU" is missing, with no default

> readLines("~/.Rprofile")
[1] "Sys.setenv(BINPREF = \"C:/Rtools/mingw_$(WIN)/bin/\")"
[2] "Sys.setenv(BINPREF = \"C:/Rtools/mingw_$(WIN)/bin/\")"

> readLines("~/.Renviron")
[1] "PATH=\"${RTOOLS40_HOME}\\usr\\bin;${PATH}\""