Open billdenney opened 5 years ago
Thanks to some further investigation by @wlandau, he found that a class was being defined during sampling. I believe that the issue is related to the following lines:
Given that the class is defined to be named as a md5, I do assume that it can't be defined in advance. But, could the class be placed into a model-specific namespace instead of the global namespace?
I think the error is somewhere else, as the rstan3 code is not used in the current package. You should look instead under rstan/rstan
.
A quick search for .GlobalEnv or globalenv() didn't reveal any obvious culprit to me (the places I found were used for reading from rather than writing to), but I don't really know the internals, so that writing to the global namespace may happen somewhere else.
I think that I traced the issue to this line:
If I am following the rest of the error trace (https://github.com/ropensci/drake/issues/960#issuecomment-544301968), this relates to loading an Rcpp shared library and being able to access shared library. The assignment to the global environment appears to happen via Rcpp, but I wonder if it can be avoided in some way?
I am not sure. That is really old code, and I'm not sure what the reasons were for putting the module into the global environment, but Rcpp Modules are pretty fragile.
Summary:
stan()
writes some object to the global namespace during sampling causing an error with thedrake
package (see ropensci/drake#960).Description:
When trying to use
stan()
within adrake
workflow, stan reaches outside its own namespace to write objects to the global namespace. It would be helpful if all writing could be to an object-specific namespace to enable the use ofdrake
for reproducible analysis.More details are in ropensci/drake#960.
Reproducible Steps:
Created on 2019-07-28 by the reprex package (v0.3.0)
Session info
``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.6.1 (2019-07-05) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> ctype English_United States.1252 #> tz America/New_York #> date 2019-07-28 #> #> - Packages -------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) #> backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0) #> base64url 1.4 2018-05-14 [1] CRAN (R 3.6.0) #> callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.1) #> cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0) #> codetools 0.2-16 2018-12-24 [2] CRAN (R 3.6.1) #> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0) #> devtools 2.1.0 2019-07-06 [1] CRAN (R 3.6.1) #> digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.1) #> dplyr 0.8.3 2019-07-04 [1] CRAN (R 3.6.1) #> drake * 7.4.0 2019-06-07 [1] CRAN (R 3.6.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1) #> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.1) #> ggplot2 * 3.2.0 2019-06-16 [1] CRAN (R 3.6.0) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0) #> gridExtra 2.3 2017-09-09 [1] CRAN (R 3.6.0) #> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0) #> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.0) #> igraph 1.2.4.1 2019-04-22 [1] CRAN (R 3.6.0) #> inline 0.3.15 2018-05-18 [1] CRAN (R 3.6.0) #> knitr 1.23 2019-05-18 [1] CRAN (R 3.6.1) #> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0) #> loo 2.1.0 2019-03-13 [1] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) #> matrixStats 0.54.0 2018-07-23 [1] CRAN (R 3.6.0) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0) #> pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1) #> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.6.0) #> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.0) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0) #> processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0) #> purrr 0.3.2 2019-03-15 [1] CRAN (R 3.6.0) #> R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0) #> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.6.0) #> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1) #> rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.1) #> rmarkdown 1.14 2019-07-12 [1] CRAN (R 3.6.1) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0) #> rstan * 2.19.2 2019-07-09 [1] CRAN (R 3.6.1) #> scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) #> StanHeaders * 2.18.1-10 2019-06-14 [1] CRAN (R 3.6.1) #> storr 1.2.1 2018-10-18 [1] CRAN (R 3.6.0) #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) #> testthat 2.1.1 2019-04-23 [1] CRAN (R 3.6.0) #> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.1) #> tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.0) #> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.1) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) #> xfun 0.8 2019-06-25 [1] CRAN (R 3.6.1) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0) #> #> [1] C:/Users/Bill Denney/Documents/R/win-library/3.6 #> [2] C:/Program Files/R/R-3.6.1/library ```Current Output:
An error is the current output.
Expected Output:
I expect the model to run and return a
stanfit
object.RStan Version:
The version of RStan you are running: 2.19.2, GitRev: 2e1f913d3ca3
R Version:
The version of R you are running: 3.6.1 (2019-07-05)
Operating System:
Your operating system: Windows 10 x64