Skip to content

Commit 2d2ea7a

Browse files
committed
Toolchain path
1 parent 7c28d7e commit 2d2ea7a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

R/install.R

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
"\nInstallation of the toolchain failed. Try reinstalling RTools and trying again.",
654655
"\nIf 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+
848861
rtools4x_toolchain_path <- function() {
849862
if (rtools4x_version() == "40") {
850863
toolchain_folder <- "mingw64"

R/utils.R

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,7 @@ is_rosetta2 <- function() {
8686
# Returns the type of make command to use to compile depending on the OS
8787
make_cmd <- function() {
8888
if (os_is_windows() && !os_is_wsl()) {
89-
if (R.version$major == "3") {
90-
make_folder <- file.path(Sys.getenv("RTOOLS35_HOME"), "mingw_64", "bin")
91-
} else if (rtools4x_version() == "40") {
92-
make_folder <- file.path(rtools4x_home_path(), "mingw64", "bin")
93-
} else {
94-
make_folder <- file.path(rtools4x_home_path(), "ucrt64", "bin")
95-
}
96-
repair_path(file.path(make_folder, "mingw32-make.exe"))
89+
repair_path(file.path(rtools_make_path(), "mingw32-make.exe"))
9790
} else {
9891
"make"
9992
}

0 commit comments

Comments
 (0)