Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jul 17, 2022
1 parent 346319f commit 9f4e8a6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Authors@R:
person(given = "Mike", family = "Lawrence", role = "ctb"),
person(given = c("William", "Michael"), family = "Landau", role = "ctb",
email = "[email protected]", comment = c(ORCID = "0000-0003-1878-3253")),
person(given = "Jacob", family = "Socolar", role = "ctb"))
person(given = "Jacob", family = "Socolar", role = "ctb"),
person(given = "Andrew", family = "Johnson", role = "ctb",
comment = c(ORCID = "0000-0001-7000-8065 ")))
Description: A lightweight interface to 'Stan' <https://mc-stan.org>.
The 'CmdStanR' interface is an alternative to 'RStan' that calls the command
line interface for compilation and running algorithms instead of interfacing
Expand Down
8 changes: 7 additions & 1 deletion R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ install_cmdstan <- function(dir = NULL,
# Use environment variable to record WSL usage throughout install,
# post-installation will simply check for 'wsl-' prefix in cmdstan path
if (isTRUE(wsl)) {
Sys.setenv("CMDSTANR_USE_WSL" = 1)
if (!os_is_windows()) {
warning("wsl=TRUE is only available on Windows, and will be ignored!",
call. = FALSE)
wsl <- FALSE
} else {
Sys.setenv("CMDSTANR_USE_WSL" = 1)
}
}
if (check_toolchain) {
check_cmdstan_toolchain(fix = FALSE, quiet = quiet)
Expand Down
1 change: 1 addition & 0 deletions R/path.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set_cmdstan_path <- function(path = NULL) {
path <- absolute_path(path)
.cmdstanr$PATH <- path
.cmdstanr$VERSION <- read_cmdstan_version(path)
.cmdstanr$WSL <- grepl("wsl-cmdstan", path)
message("CmdStan path set to: ", path)
} else {
warning("Path not set. Can't find directory: ", path, call. = FALSE)
Expand Down
10 changes: 1 addition & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ os_is_windows <- function() {
}

os_is_wsl <- function() {
# Avoid errors if checking cmdstan_path before it has been set
wsl_in_path <- tryCatch({
grepl("wsl-cmdstan", cmdstan_path())
}, error = function(e) {
FALSE
}, warning = function(e) {
FALSE
})
os_is_windows() && (wsl_in_path || Sys.getenv("CMDSTANR_USE_WSL") == 1)
os_is_windows() && (isTRUE(.cmdstanr$WSL) || Sys.getenv("CMDSTANR_USE_WSL") == 1)
}

os_is_macos <- function() {
Expand Down

0 comments on commit 9f4e8a6

Please sign in to comment.