Rstan installation problem

Hi,
I had Rstan running, it took one hour for my computer while it took 1 minute on other people’s computer. So I decided to reinstall R, Rstudio, Rstan, and Rtools. However, after I re-installed everything,

  1. it runs fine for extremely simple code,
  2. regular IRT takes 10 minutes too run (too long),
  3. my regular model will not run. It gives the error “Error: cannot allocate vector of size 16687.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”

I suspect the installation is not perfect, and tried all the suggestions I got from the internet and other people, but still doesn’t work. I’d really appreciate it if you could help.
Thank you!

What is Sys.getenv("PATH")?

Thank you for helping.

It returens:

“C:\rtools40\usr\bin;C:\oracle\product\11.2.0\client_1\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\oracle\product\11.2.0\client_1\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\1E\Client\Extensibility\NomadBranch;C:\Program Files\1E\NomadBranch\;C:\rtools40\mingw64\bin;C:\rtools40\mingw_64\bin\g++;C:\rtools40\mingw_64\bin\g++.exe;C:\Users\jgao\AppData\Local\Microsoft\WindowsApps;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\2020 MIRT - shelby\64 bit;”

I don’t think C:\rtools40\usr\bin is a valid directory. In R, what is

Sys.getenv("RTOOLS40_HOME")

? Also, while C:\rtools40\mingw64\bin is valid, it might need to be higher up on the PATH, and both copies of C:\rtools40\mingw_64\bin\g++ on the PATH should be deleted because they are executables rather than directories. In short, whoever or whatever set your PATH environmental variable did it wrong.

Can you go through the R4.0 installation instructions here: https://github.com/stan-dev/rstan/wiki/Installing-RStan-from-source-on-Windows#r40

That will help debug your setup