r-lib/pkgbuild

Rtools 4.2 is found even if 4.3 is available when using R 4.3 on Windows

cderv opened this issue · 2 comments

cderv commented

Installing RTools on Windows sets some environment variable

RTOOLS40_HOME                            C:\rtools40
RTOOLS42_HOME                            C:\rtools42
RTOOLS43_HOME                            C:\rtools43

Currently RTOOLS43_HOME is not taken into account and the 4.2 one gets selected

pkgbuild/R/rtools.R

Lines 24 to 58 in 435c2b7

has_rtools <- function(debug = FALSE) {
if (!debug && rtools_path_is_set()) {
return(!identical(rtools_path(), ""))
}
if (!is_windows()) {
return(FALSE)
}
# R 4.2.x or later and ucrt?
ucrt <- is_ucrt()
if (ucrt) {
rtools42_home <- Sys.getenv("RTOOLS42_HOME", "C:\\rtools42")
if (file.exists(file.path(rtools42_home, "usr", "bin"))) {
if (debug) {
cat("Found in Rtools 4.2 installation folder\n")
}
rtools_path_set(rtools(rtools42_home, "4.2"))
return(TRUE)
}
}
# In R 4.0 we can use RTOOLS40_HOME, recent versions of Rtools40 work fine
# with ucrt as well, currently.
if (is_R4()) {
rtools40_home <- Sys.getenv("RTOOLS40_HOME", "C:\\rtools40")
fld <- if (ucrt) "ucrt64" else "usr"
if (file.exists(file.path(rtools40_home, fld, "bin"))) {
if (debug) {
cat("Found in Rtools 4.0 installation folder\n")
}
rtools_path_set(rtools(rtools40_home, "4.0"))
return(TRUE)
}
}

Closed by b3c5f85

cderv commented

Thank you !