Skip to content

Commit

Permalink
Merge pull request #1038 from bschneidr/master
Browse files Browse the repository at this point in the history
For #1026: update `repair_path()` to work with network paths, add test.
  • Loading branch information
jgabry authored Nov 20, 2024
2 parents bceb482 + bdb6042 commit 19e7af8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ repair_path <- function(path) {
}
path <- path.expand(path)
path <- gsub("\\\\", "/", path)
# WSL cmdstan path is a network path and needs the leading //
path <- gsub("//(?!wsl)", "/", path, perl = TRUE)
# Network paths (such as the cmdstan path on WSL) need the leading //
# https://github.com/stan-dev/cmdstanr/issues/1026
path <- gsub("(?<!^)//", "/", path, perl = TRUE)
# remove trailing "/"
path <- gsub("/$","", path)
path
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ test_that("cmdstan_diagnose works if bin/diagnose deleted file", {
test_that("repair_path() fixes slashes", {
# all slashes should be single "/", and no trailing slash
expect_equal(repair_path("a//b\\c/"), "a/b/c")
# but leading double slash is needed for UNC paths on (e.g. the cmdstan path on WSL)
expect_equal(repair_path("\\\\wsl//my-project//"), "//wsl/my-project")
})

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

0 comments on commit 19e7af8

Please sign in to comment.