Open davharris opened 7 years ago
We already import all of Rcpp within the rstan NAMESPACE
https://github.com/stan-dev/rstan/blob/develop/rstan/rstan/NAMESPACE#L13
I agree this is annoying, but I don't know what to do.
Looks like importing isn't always sufficient (according to the thread I linked to above, "plain import(Rcpp)
sometimes works", but not always).
From the little bit I understand, I think this boils down to how Stan uses (or doesn't use) modules. The vignette seems to make some suggestions in Section 3. Depending on how rstan is currently set up, it might just require a call to loadModule
.
The rstan package only uses modules at runtime when the Stan program is compiled and dynamically loaded into the R session. Most of the documentation assumes Rcpp is being used at installation / build time. I think rstan only calls the Module
function, which is pretty similar to loadModule
in the sense that loadModule
calls Module
.
Adding to davharris's intial summary of the issue, it seems this occurs whenever rstan functions are called without attaching rstan first, ie. via rstan::
, not just from within packages. I.e., replacing the calls to stan_model
and sampling
with rstan::stan_model
and rstan::sampling
and in his test function and simply defining and running test()
in interactive mode causes the same error to appear.
Summary:
Downstream packages can't use rstan without
depends
ing on Rcpp, which would pollute the user's namespaceDescription:
This was previously discussed in #176.
The Rcpp developers have discussed improved solutions in the last week or so on https://github.com/RcppCore/Rcpp/issues/168; If I understand correctly, it might be solvable by adding
importFrom(Rcpp, evalCpp)
to the NAMESPACE.Reproducible Steps:
(via a mini package I created to demonstrate the issue)
Current Output:
Expected Output:
an 8-schools
stanfit
RStan Version:
2.12.1
R Version:
R version 3.3.2 (2016-10-31)
Operating System:
10.12.1