Skip to content

Commit c2ef835

Browse files
committed
Final check
1 parent 22728e8 commit c2ef835

8 files changed

Lines changed: 23 additions & 146 deletions

File tree

.github/workflows/R-CMD-check-wsl.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ name: Unit tests - WSL Backend
1313
- master
1414

1515
jobs:
16-
R-CMD-check:
16+
WSL-R-CMD-check:
1717
if: "! contains(github.event.head_commit.message, '[ci skip]')"
1818
runs-on: windows-latest
1919

20-
name: WSL1 Backend
20+
name: windows-latest-WSLv1
2121

2222
env:
2323
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
@@ -65,7 +65,7 @@ jobs:
6565
set-as-default: 'true'
6666
- name: Install WSL Dependencies
6767
run: |
68-
# Bugfix for current gzip under WSLv1:
68+
# Bugfix for current gzip (for unpacking apt packages) under WSLv1:
6969
# https://github.com/microsoft/WSL/issues/8219#issuecomment-1110508016
7070
echo -en '\x10' | sudo dd of=/usr/bin/gzip count=1 bs=1 conv=notrunc seek=$((0x189))
7171
sudo apt-get update

.github/workflows/Test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Test coverage
77
'on':
88
push:
99
branches:
10-
- wsl-support
10+
- master
1111
pull_request:
1212
branches:
1313
- master

.github/workflows/mpi.yaml

Lines changed: 0 additions & 129 deletions
This file was deleted.

R/csv.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,14 @@ read_csv_metadata <- function(csv_file) {
734734
if (length(gradients) > 0) {
735735
csv_file_info$gradients <- gradients
736736
}
737+
738+
# Revert any WSL-updated paths before returning the metadata
737739
if (os_is_wsl()) {
738740
csv_file_info$init <- wsl_safe_path(csv_file_info$init, revert = TRUE)
739741
csv_file_info$profile_file <- wsl_safe_path(csv_file_info$profile_file,
740-
revert = TRUE)
742+
revert = TRUE)
741743
csv_file_info$fitted_params <- wsl_safe_path(csv_file_info$fitted_params,
742-
revert = TRUE)
744+
revert = TRUE)
743745
}
744746
csv_file_info
745747
}

R/install.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ install_cmdstan <- function(dir = NULL,
213213
"\nrebuild_cmdstan(cores = ...)"
214214
)
215215
}
216-
217216
if (isTRUE(wsl)) {
218217
Sys.unsetenv("CMDSTANR_USE_WSL")
219218
}

R/model.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,7 @@ include_paths_stanc3_args <- function(include_paths = NULL) {
17601760
stancflags <- NULL
17611761
if (!is.null(include_paths)) {
17621762
checkmate::assert_directory_exists(include_paths, access = "r")
1763-
include_paths <- absolute_path(include_paths)
1764-
include_paths <- sapply(include_paths, wsl_safe_path)
1763+
include_paths <- sapply(absolute_path(include_paths), wsl_safe_path)
17651764
paths_w_space <- grep(" ", include_paths)
17661765
include_paths[paths_w_space] <- paste0("'", include_paths[paths_w_space], "'")
17671766
include_paths <- paste0(include_paths, collapse = ",")
@@ -1782,11 +1781,12 @@ model_variables <- function(stan_file, include_paths = NULL, allow_undefined = F
17821781
allow_undefined_arg <- NULL
17831782
}
17841783
out_file <- tempfile(fileext = ".json")
1785-
stan_file <- stan_file
17861784
run_log <- wsl_compatible_run(
17871785
command = stanc_cmd(),
1788-
args = c(wsl_safe_path(stan_file), "--info", include_paths_stanc3_args(include_paths),
1789-
allow_undefined_arg),
1786+
args = c(wsl_safe_path(stan_file),
1787+
"--info",
1788+
include_paths_stanc3_args(include_paths),
1789+
allow_undefined_arg),
17901790
wd = cmdstan_path(),
17911791
echo = FALSE,
17921792
echo_cmd = FALSE,

R/path.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ cmdstan_default_install_path <- function(old = FALSE) {
121121
#' Returns the path to the installation of CmdStan with the most recent release
122122
#' version.
123123
#'
124+
#' For Windows systems with WSL CmdStan installs, if there are side-by-side WSL
125+
#' and native installs with the same version then the WSL is preferred.
126+
#' Otherwise, the most recent release is chosen, regardless of whether it is
127+
#' native or WSL.
128+
#'
124129
#' @export
125130
#' @keywords internal
126131
#' @param old See [cmdstan_default_install_path()].

R/utils.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ wsl_safe_path <- function(path = NULL, revert = FALSE) {
169169
} else {
170170
path_already_safe <- grepl("^/mnt/", path)
171171
if (os_is_wsl() && !isTRUE(path_already_safe) && !is.na(path)) {
172-
abs_path <- repair_path(path)
172+
abs_path <- repair_path(utils::shortPathName(path))
173173
drive_letter <- tolower(strtrim(abs_path, 1))
174174
path <- gsub(paste0(drive_letter, ":"),
175175
paste0("/mnt/", drive_letter),
@@ -180,15 +180,15 @@ wsl_safe_path <- function(path = NULL, revert = FALSE) {
180180
path
181181
}
182182

183+
# Running commands through WSL requires using 'wsl' as the command with the
184+
# intended command (e.g., stanc) as the first argument. This function acts as
185+
# a wrapper around processx::run() to apply this change where necessary, and
186+
# forward all other arguments
183187
wsl_compatible_run <- function(...) {
184188
run_args <- list(...)
185189
if (os_is_wsl()) {
186190
command <- run_args$command
187191
run_args$command <- "wsl"
188-
if (grepl("stanc", command)) {
189-
run_args$args[1] <- paste0("'", run_args$args[1], "'")
190-
run_args$windows_verbatim_args <- TRUE
191-
}
192192
run_args$args <- c(command, run_args$args)
193193
}
194194
do.call(processx::run, run_args)

0 commit comments

Comments
 (0)