Skip to content

Commit

Permalink
use try() instead of file.exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoodri committed Oct 10, 2023
1 parent 796f868 commit 60a231e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rstan/rstan/R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ OUT <- 0
assign("stanc_ctx", V8::v8(), envir = topenv())
} else assign("stanc_ctx", QuickJSR::JSContext$new(stack_size = 4 * 1024 * 1024), envir = topenv())
stanc_js <- system.file("stanc.js", package = "StanHeaders", mustWork = TRUE)
if (!file.exists(stanc_js)) {
test <- try(stanc_ctx$source(stanc_js), silent = TRUE)
if (inherits(test, "try-error")) {
stanc_js <- system.file("exec", "stanc.js", package = "rstan", mustWork = TRUE)
stanc_ctx$source(stanc_js)
}
stanc_ctx$source(stanc_js)
assignInMyNamespace("rstan_load_time", value = Sys.time())
Expand Down

0 comments on commit 60a231e

Please sign in to comment.