Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand default RTools toolchain usage to all R versions #1065

Merged
merged 3 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
#' C++ toolchain. It is called internally by `install_cmdstan()` but can also
#' be called directly by the user. On Windows only, calling the function with
#' the `fix = TRUE` argument will attempt to install the necessary toolchain
#' components if they are not found. For Windows users with RTools44 no additional
#' toolchain configuration is required. For users with older versions of RTools,
#' the function will install `mingw32-make` and `g++` from MSYS using the
#' RTools-provided `pacman` package manager. This can also be manually requested
#' by setting the environment variable `CMDSTANR_USE_MSYS_TOOLCHAIN` to 'true'
#' components if they are not found. For Windows users with RTools and CmdStan
#' versions >= 2.35 no additional toolchain configuration is required.
#'
#' NOTE: When installing CmdStan on Windows with RTools44 and CmdStan versions
#' NOTE: When installing CmdStan on Windows with RTools and CmdStan versions
#' prior to 2.35.0, the above additional toolchain configuration
#' is still required. To enable this configuration, set the environment variable
#' `CMDSTANR_USE_MSYS_TOOLCHAIN` to 'true' and call
Expand Down Expand Up @@ -115,9 +112,9 @@ install_cmdstan <- function(dir = NULL,
.cmdstanr$WSL <- FALSE
}
if (os_is_windows() && !os_is_wsl() && isTRUE(version < "2.35.0")) {
# RTools44 can be used unmodified with CmdStan 2.35+
# RTools can be used unmodified with CmdStan 2.35+
# For new installs of older versions, users need to install mingw32-make and MSYS gcc
if (Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") == "" && rtools4x_version() == "44") {
if (Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") == "") {
stop("CmdStan versions prior to 2.35.0 require additional toolchain configuration on Windows.\n",
"Please set the environment variable CMDSTANR_USE_MSYS_TOOLCHAIN to 'true' and \n",
"call `check_cmdstan_toolchain(fix = TRUE)` before installing CmdStan.", call. = FALSE)
Expand Down Expand Up @@ -663,8 +660,8 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
call. = FALSE
)
}
# No additional utilities/toolchains are needed with RTools44
if (rtools4x_version() >= "44" && Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") == "") {
# No additional utilities/toolchains are needed with RTools4
if (Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") == "") {
return(invisible(NULL))
}
if (!is_toolchain_installed(app = "g++", path = toolchain_path) ||
Expand Down Expand Up @@ -879,7 +876,7 @@ rtools4x_toolchain_path <- function() {
if (arch_is_aarch64()) {
toolchain <- "aarch64-w64-mingw32.static.posix"
} else {
if (rtools4x_version() < "44" || Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") != "" ||
if (Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") != "" ||
isTRUE(cmdstan_version(error_on_NA=FALSE) < "2.35.0")) {
toolchain <- ifelse(is_ucrt_toolchain(), "ucrt64", "mingw64")
} else {
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ make_cmd <- function() {
if (Sys.getenv("MAKE") != "") {
Sys.getenv("MAKE")
} else if (os_is_windows() && !os_is_wsl() &&
(rtools4x_version() < "44" || Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") != "" || isTRUE(cmdstan_version(error_on_NA=FALSE) < "2.35.0"))) {
(Sys.getenv("CMDSTANR_USE_MSYS_TOOLCHAIN") != "" || isTRUE(cmdstan_version(error_on_NA=FALSE) < "2.35.0"))) {
"mingw32-make.exe"
} else {
"make"
Expand Down
9 changes: 3 additions & 6 deletions man/install_cmdstan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading