are you using R4.0 with Rtools 4.0? If so, can you run:
check_rtools40_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
rtools_path <- Sys.getenv("RTOOLS40_HOME")
# If RTOOLS40_HOME is not set (the env. variable gets set on install)
# we assume that RTools 40 is not installed.
if (!nzchar(rtools_path)) {
stop(
"\nRTools 4.0 was not found but is required to run CmdStan with R version 4.x.",
"\nPlease install RTools 4.0 and run check_cmdstan_toolchain().",
call. = FALSE
)
}
# If RTools is installed in a path with spaces or brackets
# we error as this path is not valid
if (regexpr("\\(|)| ", rtools_path) > 0) {
stop(
"\nRTools 4.0 is installed in a path with spaces or brackets, which is not supported.",
"\nPlease reinstall RTools 4.0 to a valid path, restart R, and then run check_cmdstan_toolchain().",
call. = FALSE
)
}
toolchain_path <- cmdstanr:::repair_path(file.path(rtools_path, "mingw64", "bin"))
mingw32_make_path <- dirname(Sys.which("mingw32-make"))
gpp_path <- dirname(Sys.which("g++"))
if (!nzchar(mingw32_make_path) || !nzchar(gpp_path)) {
if (!fix) {
stop(
"\nRTools installation found but PATH was not properly set.",
"\nRun check_cmdstan_toolchain(fix = TRUE) to fix the issue.",
call. = FALSE
)
} else {
if (!quiet) message("Installing mingw32-make and writing RTools path to ~/.Renviron ...")
install_mingw32_make()
write('PATH="${RTOOLS40_HOME}\\usr\\bin;${RTOOLS40_HOME}\\mingw64\\bin;${PATH}"', file = "~/.Renviron", append = TRUE)
Sys.setenv(PATH = paste0(Sys.getenv("RTOOLS40_HOME"), "\\usr\\bin;", Sys.getenv("RTOOLS40_HOME"), "\\mingw64\\bin;", Sys.getenv("PATH")))
check_rtools40_windows_toolchain(fix = FALSE, quiet = quiet)
return(invisible(NULL))
}
}
# Check if the mingw32-make and g++ get picked up by default are the RTools-supplied ones
if (toolchain_path != mingw32_make_path || gpp_path != toolchain_path) {
if (!fix) {
stop(
"\nOther C++ toolchains installed on your system conflict with RTools.",
"\nPlease run check_cmdstan_toolchain(fix = TRUE) to fix the issue.",
call. = FALSE
)
} else {
if (!quiet) message("Installing mingw32-make and writing RTools path to ~/.Renviron ...")
install_mingw32_make()
write('PATH="${RTOOLS40_HOME}\\usr\\bin;${RTOOLS40_HOME}\\mingw64\\bin;${PATH}"', file = "~/.Renviron", append = TRUE)
Sys.setenv(PATH = paste0(Sys.getenv("RTOOLS40_HOME"), "\\usr\\bin;", Sys.getenv("RTOOLS40_HOME"), "\\mingw64\\bin;", Sys.getenv("PATH")))
check_rtools40_windows_toolchain(fix = FALSE, quiet = quiet)
return(invisible(NULL))
}
}
}
check_rtools40_windows_toolchain()
Error:
RTools installation found but PATH was not properly set.
Run check_cmdstan_toolchain(fix = TRUE) to fix the issue.
Then I run,
check_cmdstan_toolchain(fix = TRUE)
Error in check_cmdstan_toolchain(fix = TRUE) :
could not find function “check_cmdstan_toolchain”
Hey, instead of check_cmdstan_toolchain() run check_rtools40_windows_toolchain(fix = TRUE).
The check_cmdstan_toolchain has not been exposed yet. Sorry for the errors, this function is in development right now and will be part of cmdstanr in the very near future so we can avoid the issue you are having.
It was a my error, because I didn’t check quotations.
I could run it and then run,
check_rtools40_windows_toolchain(fix = TRUE)
Why is this error occurred?
Installing mingw32-make and writing RTools path to ~/.Renviron …
Error in processx::run(“pacman”, args = c("-Syu", “mingw-w64-x86_64-make”, : System command ‘pacman’ failed, exit status: 1, stderr: E> error: target not found: �noconfirm Type .Last.error.trace to see where the error occured