RStanArm working, but RStan is unable to find C++ compiler

Strange situation. I have tried running the code from the RStanArm Vignette here: https://cran.r-project.org/web/packages/rstanarm/vignettes/pooling.html and everything runs fine. Also, when I try to use: devtools::find_rtools(TRUE), it returns TRUE, so I know that RTools is present and I do have a C++ compiler working in my system.

However, when I was trying to specify my own stan model with the command below, I get a message that says
“No C++ compiler found, so the following will probably not work.”

I am unable to do a reinstall at the moment, because I do not have admin privileges on this device (work computer). Any advice would be much appreciated!

stan(“normal.stan”,
data = list(“X”, “Y”, “N”, “Z”),
iter = 2000, chains = 4)

The rstanarm models are precompiled so that’s probably why those run fine. Unfortunately, it’s possible that even with RTools installed the compiler won’t be found. What does Sys.getenv('PATH') path return?

Have you looked at the information at the link below?

It gives a few suggestions for checking that your setup is correct.

Sys.getenv(‘PATH’) does not get me the expected folder with RTools.

What does

Sys.which("g++")

say?

I get this:

Okay that means it has no idea where g++ is. Where did you install RTools to?

Hello,
I believe I have the same situation here as author.

My Rtools installed at:
“C:\Rtools”

Output from Sys.getenv(‘PATH’) have needed parts (added by hand, Rtools installation now do not allow the step with choosing these):
C:\Rtools\bin;C:\Rtools\mingw_64\bin\\

Command “system(‘where make’)” shows correct location of file: C:\Rtools\bin\make.exe

Command “system(‘g++ -V’)” do not give any result.

When I run “fit <- stan(“some rstan model”)” it says: No C++ compiler found, so the following will probably not work.

As I find out rstanarm models are precompiled so it works and I can get a bunch of warning as well as output and can print and plot “fit”.

The warning which is not connected to the model I ran but potentially informs about some problem is:
“2: In system2(file.path(Sys.getenv(“R_HOME”), “bin”, Sys.getenv(“R_ARCH_BIN”), :
running command ‘“D:/Programs/R/R_350/bin//R” CMD config CXX’ had status 1”

I have Cygwin64 installed + NetBeans (may be some conflict)

May be someone know how to force Rstudio to see the G++ compiler? I double checked that g++.exe is located at “C:\Rtools\mingw_64\bin”

Thank you!

Likely. You can try putting

CXX = "C:\Rtools\mingw_64\bin\g++"

into the file located at ~/.R/Makevars.

Thank you for your response!
At first I add what you suggested to Makevars file.
My location for it was “D:\Documents.R”
I checked and it did not worked.
I add new ‘PATH’ which included (not sure which worked):
“C:\Rtools\mingw_64\bin\g++.exe”
“C:\Rtools\mingw_64\bin\g++”
“C:\Rtools\mingw_64\bin”

And now it works!

Thank you for help ;)