Closed andrjohns closed 9 months ago
The mustWork = TRUE
argument to system.file
already requires the file to exist, but if it exists in the corrupted state, it will cause things to break. I will put this in .onLoad in the the 2.32 branch to get around it:
stanc_js <- system.file("stanc.js", package = "StanHeaders", mustWork = TRUE)
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)
}
Summary:
The
onLoad
action forrstan
currently uses the$validate()
member function to check thestanc.js
inStanHeaders
, and if the check fails then loads thestanc.js
fromrstan
. However,$validate()
assumes that the input is a string of JS code, not a file path. This means that the check is alwaysFALSE
, and therstan
stanc.js
is always loaded.This PR simplifies that to just checking whether the file exists.
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Andrew Johnson
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: