H:/rtools40/usr/mingw_/bin/g++ not found

Start with a short summary of your inquiry.
I have installed r Stan as described on the website


Now i decide to run my code - the school data code but I have this error:

H:/rtools40/usr/mingw_/bin/g++ not found

Don’t forget to attach tags (top right of this form) for application area/class of models or other general subject areas your topic touches on.

when i type system('g++ -v) i get 127

@andrjohns is this the problem many ppl have been facing on Windows?

1 Like

Hi Chinyereugo,

That warning is safe to ignore.

Does the model compile and sample and then just display that warning at the end?

the model does not compile.

the model does not compile

So this is what I get when as output:

‘H:/rtools40/usr/mingw_/bin/g++’ not foundrunning command ‘C:/PROGRA~1/R/R-40~1.2/bin/x64/R CMD SHLIB file314c20c1271.cpp 2> file314c20c1271.cpp.err.txt’ had status 1cannot open file ‘file314c20c1271.cpp.err.txt’: No such file or directoryError in file(con, “r”) : cannot open the connection
Error in sink(type = “output”) : invalid connection

Can you run:

install.packages("inline")
library(rstan)
example(stan_model,run.dontrun=TRUE,verbose=TRUE)

And post any lines that start with error:?

Hello Andrew,
I ran the code suggested and still the error has not changed.
First error is: H:/rtools40/m… not found
and the others are on the screen shots sent previous.

Thanks in advance

Can you post the outputs from:

Sys.getenv("PATH")
devtools::session_info("rstan")

Can you run:

install.packages("devtools")
devtools::session_info("rstan")

Can you run:

unlink("H:\R\win-library\4.0\00LOCK")
install.packages("devtools")

Sorry that should be:

unlink("H:/R/win-library/4.0/00LOCK")
install.packages("devtools")

Same issue.

May be I could try reinstalling Rstudio and Rstan

Can you try restarting RStudio and trying to install the package again?

Just did that and same results. Let me uninstall Rstudio and reinstall it again.
May be this can help

Thank you so much.

I don’t think reinstalling RStudio will help this, since the error is R is not being able to write to the directory.

Can you go to H:/R/win-library/4.0/ and delete the 00LOCK folder?