Troubles with rstan_package_skeleton()

I’m trying to create an R package that will have precompiled Stan models in it, working in RStudio. I followed the instructions for rstan_package_skeleton(), but when I do dev_tools::load_all(".") or dev_tools::document() I get the error message

Error in is(module, "character") : object 'm' not found

I have no idea what this even means, much less what to do about it. Any idea?

There’s not much in the package yet – just a data set, its documentation, and a script to create it.

Operating System: Mac OS X 10.13.6 (High Sierra)
Interface Version: rstantools 1.5.1, rstan 2.17.4
Compiler/Toolkit:

I think this failure is due to not having any Stan programs yet. Once those exist and are under src/stan_models then the .onLoad() function in the R/zzz.R file will work with the R/stanmodels.R file to create those modules and then loop over m to load them.

More specifically, the new version of roxygen2 is now trying to call load_all on the code in order to build the documentation, but this fails when there are no Stan programs.

I added one Stan model, and the result is that devtools::install(local=FALSE) succeeds, but devtools::load_all(".") and devtools::document() still faile with the “object ‘m’ not found” error.

Not too surprising. We are working on getting a rstantools release that is compatible with Stan 2.18.

I’m confused. RStan is only up to version 2.17.4, which I understood to correspond to Stan 2.17.x, not 2.18.

2.18 is on CRAN but there are no binaries yet for Windows version 3.5

I’m seeing this problem both with RStan 2.17.4 and RStan 2.18.1, even though I have a “.stan” source file. With RStan 2.18.1 I now find that devtools::install(local=FALSE) doesn’t work – I get the same “object 'm' not found” error.

I need to get this package built one way or another, but I am now completely blocked by this problem. What sort of workarounds are there?

Hmmm, turns out that devtools::install failed because I was generating my .stan file. After redoing my mods to Makevars to ensure that the generated files stick around long enough, devtools::install worked.

remotes::install_github("stan-dev/rstantools", ref = "mlysy-rstantools_patch", 
                        build_opts = " ")

which will be something like the next rstantools release.