R CMD check fails after adding Stan infrastructure to an existing R package

@andrjohns

Based on your guidelines here, I used the following workaround, which successfully compiled the example stan model locally:

  1. Have an empty Makevars file.
  2. The Makevars.win file contains the following:
CXX14 = "C:/RBuildTools/3.5/mingw_64/bin/g++.exe" -std=c++1y
CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2
  1. Rename Makevars.win to Makevars.win.bak:
file.rename("~/.R/Makevars.win", "~/.R/Makevars.win.bak")
  1. Execute example(stan_model,package="rstan",run.dontrun=T). At the end of the execution, I receive the following warning message:
    2021-06-25_15h39_37

Testing this strategy on the compilation of the R package fails. devtools::check() yields:

i Updating Bernadette documentation
i Loading Bernadette
Error in Rcpp::loadModule(module = "stan_fit4dummy_lm_model_mod", what = TRUE,  : 
  Unable to load module "stan_fit4dummy_lm_model_mod": Failed to initialize module pointer: Error in FUN(X[[i]], ...): no such symbol _rcpp_module_boot_stan_fit4dummy_lm_model_mod in package Bernadette
Calls: <Anonymous> ... <Anonymous> -> run_ns_load_actions -> action -> <Anonymous>
Execution halted

Exited with status 1.