@@ -556,7 +556,7 @@ install_toolchain <- function(quiet = FALSE) {
556556 rtools_usr_bin <- file.path(rtools4x_home_path(), " usr" , " bin" )
557557 rtools_version <- paste0(" Rtools" , rtools4x_version())
558558 if (is_ucrt_toolchain()) {
559- install_pkgs <- c(" mingw-w64-ucrt-x86_64-make" , " mingw-w64-ucrt-x86_64-gcc " )
559+ install_pkgs <- c(" mingw-w64-ucrt-x86_64-make" )
560560 if (! quiet ) message(paste0(" Installing mingw32-make and g++ with " , rtools_version ))
561561 } else {
562562 install_pkgs <- " mingw-w64-x86_64-make"
@@ -618,6 +618,7 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
618618 rtools_path <- rtools_home_path()
619619 rtools_version <- paste0(" Rtools" , rtools4x_version())
620620 toolchain_path <- rtools4x_toolchain_path()
621+ make_path <- rtools_make_path()
621622 # If RTOOLS4X_HOME is not set (the env. variable gets set on install)
622623 # we assume that RTools 40 is not installed.
623624 if (! nzchar(rtools_path )) {
@@ -638,7 +639,7 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
638639 )
639640 }
640641 if (! is_toolchain_installed(app = " g++" , path = toolchain_path ) ||
641- ! is_toolchain_installed(app = " mingw32-make" , path = toolchain_path )) {
642+ ! is_toolchain_installed(app = " mingw32-make" , path = make_path )) {
642643 if (! fix ) {
643644 stop(
644645 " \n " , rtools_version , " installation found but the toolchain was not installed." ,
@@ -648,7 +649,7 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
648649 } else {
649650 install_toolchain(quiet = quiet )
650651 if (! is_toolchain_installed(app = " g++" , path = toolchain_path ) ||
651- ! is_toolchain_installed(app = " mingw32-make" , path = toolchain_path )) {
652+ ! is_toolchain_installed(app = " mingw32-make" , path = make_path )) {
652653 stop(
653654 " \n Installation of the toolchain failed. Try reinstalling RTools and trying again." ,
654655 " \n If the issue persists, open a bug report at https://github.com/stan-dev/cmdstanr." ,
@@ -845,6 +846,18 @@ toolchain_PATH_env_var <- function() {
845846 path
846847}
847848
849+ rtools_make_path <- function () {
850+ make_folder <- " "
851+ if (R.version $ major == " 3" ) {
852+ make_folder <- file.path(Sys.getenv(" RTOOLS35_HOME" ), " mingw_64" , " bin" )
853+ } else if (rtools4x_version() == " 40" ) {
854+ make_folder <- file.path(rtools4x_home_path(), " mingw64" , " bin" )
855+ } else {
856+ make_folder <- file.path(rtools4x_home_path(), " ucrt64" , " bin" )
857+ }
858+ repair_path(make_folder )
859+ }
860+
848861rtools4x_toolchain_path <- function () {
849862 if (rtools4x_version() == " 40" ) {
850863 toolchain_folder <- " mingw64"
0 commit comments