Problem with using rstan_package_skeleton

I am trying to develop an R package that depends on Stan and I get an immediate problem if I use rstan_package_skeleton as described in “Step by Step Guide for creating a package that depends on Stan”. The problem seems to arise from the zzz.R file line:

  modules <- paste0("stan_fit4", names(stanmodels), "_mod")
  for (m in modules) loadModule(m, what = TRUE)

because when I run rstan_package_skeleton the output includes the error message: “Error in is(module, “character”) : object ‘m’ not found”.
Although the package appears nevertheless to have been created, I get the same error message when I use dev_tools::document(). If I simply delete the zzz.R file document() runs normally.

I think that means it did not find any Stan models. Do you have a link to it on GitHub?

Ah! That’s all right: I haven’t incorporated the Stan models yet, so I’ll just ignore the error for now.

I now have: error goes. But this error will always occur, surely, because when one runs rstan_package_skeleton there cannot yet be any Stan models?

That is what the stan_files argument to rstan_package.skeleton is for.

True, but the step by step guide does say that there is the option of adding them later.

Yeah, I guess it doesn’t say you have to tolerate errors in the meantime, but typically someone should have a working Stan program before starting to write a R package around it.