Error finding RTools 4.0

Hi,

My model is not compiling. when I run cmdstan_model(), I get the following error

Compiling Stan program…
Error in rethrow_call(c_processx_exec, command, c(command, args), stdin, :
Command ‘mingw32-make.exe’ not found @win/processx.c:994 (processx_exec)
Type .Last.error.trace to see where the error occured

All of my code was working before the weekend.

I can run the example model fine

stan_file ← file.path(cmdstan_path(), “examples”, “bernoulli”, “bernoulli.stan”)
mod ← cmdstan_model(stan_file)
Model executable is up to date!

But it will not work for my own model. I ran the following

cmdstanr::check_cmdstan_toolchain(fix=TRUE)
Error:
RTools 4.0 was not found but is required to run CmdStan with R version 4.x.
Please install RTools 4.0 and run check_cmdstan_toolchain().

I have RTools 4.0 on my computer and have added it successfully to my path via

Sys.setenv(PATH = paste(old_path, “C:\rtools40\usr\bin;”, sep = “”))
Sys.getenv(“PATH”)

But I still get the same error message when I run cmdstan_model().

Any suggestions?

Hi,

the following error

Error:
RTools 4.0 was not found but is required to run CmdStan with R version 4.x.
Please install RTools 4.0 and run check_cmdstan_toolchain().

is printed because Sys.getenv("RTOOLS40_HOME") seems to not exist. I am not sure why that would not exist if you have RTools 4.0 installed. Any new Rtools 4.0 installation will add this environment variable to Windows automatically (its use is mentioned in the basic instructions: https://cran.r-project.org/bin/windows/Rtools/#putting-rtools-on-the-path).

Is you Rtools 4.0 installation from the Rtools 4.0 beta stage maybe?

I would suggest you add this environment variable by running:
write('RTOOLS40_HOME="C:\rtools40"', file = "~/.Renviron", append = TRUE)
or simply reinstall RTools 4.0.

Thank you. I reinstalled Rtools 4.0, updated the .Renviron file as per: https://cran.r-project.org/bin/windows/Rtools/#putting-rtools-on-the-path
, and ran cmdstanr::check_cmdstan_toolchain(fix=TRUE) which fixed the issue.

1 Like