Skip to content

Commit 19e7af8

Browse files
authored
Merge pull request #1038 from bschneidr/master
For #1026: update `repair_path()` to work with network paths, add test.
2 parents bceb482 + bdb6042 commit 19e7af8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

R/utils.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ repair_path <- function(path) {
128128
}
129129
path <- path.expand(path)
130130
path <- gsub("\\\\", "/", path)
131-
# WSL cmdstan path is a network path and needs the leading //
132-
path <- gsub("//(?!wsl)", "/", path, perl = TRUE)
131+
# Network paths (such as the cmdstan path on WSL) need the leading //
132+
# https://github.com/stan-dev/cmdstanr/issues/1026
133+
path <- gsub("(?<!^)//", "/", path, perl = TRUE)
133134
# remove trailing "/"
134135
path <- gsub("/$","", path)
135136
path

tests/testthat/test-utils.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ test_that("cmdstan_diagnose works if bin/diagnose deleted file", {
143143
test_that("repair_path() fixes slashes", {
144144
# all slashes should be single "/", and no trailing slash
145145
expect_equal(repair_path("a//b\\c/"), "a/b/c")
146+
# but leading double slash is needed for UNC paths on (e.g. the cmdstan path on WSL)
147+
expect_equal(repair_path("\\\\wsl//my-project//"), "//wsl/my-project")
146148
})
147149

148150
test_that("repair_path works with zero length path or non-string path", {

0 commit comments

Comments
 (0)