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

Add CMDSTANR_USE_RTOOLS envvar to force use of stock RTools #980

Merged
merged 4 commits into from
May 22, 2024
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
12 changes: 11 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ jobs:
echo "CMDSTAN_PATH=${HOME}/.cmdstan" >> $GITHUB_ENV
shell: bash

- name: Use stock RTools for Windows R-Devel
if: ${{ matrix.config.os == 'windows-latest' && matrix.config.r == 'devel' }}
run: |
echo "CMDSTANR_USE_RTOOLS=TRUE" >> $GITHUB_ENV
shell: bash

- uses: n1hility/cancel-previous-runs@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -63,7 +69,11 @@ jobs:
- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan(cores = 2)
if (Sys.getenv("CMDSTANR_USE_RTOOLS") == "TRUE") {
cmdstanr::install_cmdstan(cores = 2, version = "2.35.0-rc2")
} else {
cmdstanr::install_cmdstan(cores = 2)
}
shell: Rscript {0}

- name: Session info
Expand Down
10 changes: 8 additions & 2 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
call. = FALSE
)
}
if (Sys.getenv("CMDSTANR_USE_RTOOLS") != "") {
return(invisible(NULL))
}
if (!is_toolchain_installed(app = "g++", path = toolchain_path) ||
!is_toolchain_installed(app = "mingw32-make", path = toolchain_path)) {
if (!fix) {
Expand Down Expand Up @@ -844,8 +847,11 @@ toolchain_PATH_env_var <- function() {
}

rtools4x_toolchain_path <- function() {
c_runtime <- ifelse(is_ucrt_toolchain(), "ucrt64", "mingw64")
repair_path(file.path(rtools4x_home_path(), c_runtime, "bin"))
toolchain <- ifelse(is_ucrt_toolchain(), "ucrt64", "mingw64")
if (Sys.getenv("CMDSTANR_USE_RTOOLS") != "") {
toolchain <- "x86_64-w64-mingw32.static.posix"
}
repair_path(file.path(rtools4x_home_path(), toolchain, "bin"))
}

rtools4x_version <- function() {
Expand Down
2 changes: 1 addition & 1 deletion R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ compile <- function(quiet = TRUE,
),
run_log <- wsl_compatible_run(
command = make_cmd(),
args = c(wsl_safe_path(tmp_exe),
args = c(wsl_safe_path(repair_path(tmp_exe)),
cpp_options_to_compile_flags(cpp_options),
stancflags_val),
wd = cmdstan_path(),
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ is_rosetta2 <- function() {

# Returns the type of make command to use to compile depending on the OS
make_cmd <- function() {
if (os_is_windows() && !os_is_wsl()) {
if (os_is_windows() && !os_is_wsl() && (Sys.getenv("CMDSTANR_USE_RTOOLS") == "")) {
"mingw32-make.exe"
} else {
"make"
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-install.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
context("install")
# Current tests need CmdStan 2.35 for stock rtools, but is not yet released
skip_if(Sys.getenv("CMDSTANR_USE_RTOOLS") != "")

cmdstan_test_tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL")
if (!nzchar(cmdstan_test_tarball_url)) {
Expand Down
Loading