Error when adding 2nd .stan file to R package with 1 compiled stan model

Hi all,

I have a working R package with a single stan function that compiles nicely on installation and works.

I followed the instructions at to set this up about 6 months ago.

My problem is now when I add a second .stan file to exec, even if it is just a renamed copy of the working model, I get this error when I try to build.

Updating baconr documentation
Loading baconr
Error in is(module, “character”) : object ‘m’ not found
Calls: suppressPackageStartupMessages … load_all -> run_ns_load_actions -> action -> loadModule -> is
In addition: Warning message:
package ‘Rcpp’ was built under R version 3.4.2
Execution halted

Exited with status 1.

The only forum replies I can find which mention this error talk about missing the useDynLib() call, but I have that.

Thanks for any help.

It works for me if I copy exec/bacon.stan to exec/bacon2.stan. My guess is that you are doing R CMD INSTALL without the --preclean option.

Hi Ben,

thanks for the reply. This might be the problem. Using "clean and rebuild"
from RStudio doesn’t fix it and I’m having some problems building from CMD
on my home machine. I’ll try to work through it tomorrow.

Is it possible that there are build artefacts that are not being

Thanks for the help.

Yes, RStudio’s clean and rebuild icon doesn’t work unless you use
as your project file. We are going to have a different build system for packages Real Soon Now that won’t require this.

But R CMD build should be working.

Hi Ben,

Thanks for the help. There were some files that were not getting
"pre-cleaned", I think Modules.cpp was the problem. Probably because I had
committed it to the git repo by mistake.