diff --git a/rstan/rstan/R/zzz.R b/rstan/rstan/R/zzz.R index 3f648c594..4cb0fade4 100644 --- a/rstan/rstan/R/zzz.R +++ b/rstan/rstan/R/zzz.R @@ -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())