Using the current CRAN versions of all involved packages (including 'rstanarm' 2.32.2, 'rstan' 2.32.7, 'StanHeaders' 2.39.1), R CMD check gives:
══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test_stan_functions.R:64:1'): (code run outside of `test_that()`) ───
Error in `expose_stan_functions(stanc_ret, rebuild = TRUE, verbose = TRUE)`: Compilation failed!
Backtrace:
▆
1. └─rstan::expose_stan_functions(stanc_ret, rebuild = TRUE, verbose = TRUE) at test_stan_functions.R:64:1
Unfortunately, the check log is not very helpful, not only because of the 'testthat' camouflage but also because rstan::expose_stan_functions runs Rcpp::sourceCpp() in try(silent=TRUE), hiding the actual error. So I inserted
trace(expose_stan_functions, quote(try <- function(..., silent) base::try(...)))
just before the expose_stan_functions call in the test script to remove its silence.
This reveals that building the shared library
g++ -std=gnu++17 -shared -L/usr/local/lib -o sourceCpp_2.so file19b9609a5bbf.o /mnt/runner/lib/rstan/lib//libStanServices.a -L/mnt/runner/lib/StanHeaders/lib/ -lStanHeaders -L/mnt/runner/lib/RcppParallel/lib/ -ltbb
succeeds, but Rcpp::sourceCpp() then fails from loading the module (source(scriptPath, local = env)):
Error in dyn.load("/tmp/RtmpoaocOG/sourceCpp-x86_64-pc-linux-musl-1.1.2/sourcecpp_49ad49147921/sourceCpp_2.so") :
unable to load shared object '/tmp/RtmpoaocOG/sourceCpp-x86_64-pc-linux-musl-1.1.2/sourcecpp_49ad49147921/sourceCpp_2.so':
Error loading shared library libtbb.so: No such file or directory
Obviously, system.file("lib", "libtbb.so", package = "RcppParallel") is available, but not normally in the runtime search path, and there is no system installation of TBB.
FWIW, I can make this test compilation work by setting
Sys.setenv(PKG_LIBS = paste0("-Wl,-rpath,", RcppParallel::tbbLibraryPath()))
before expose_stan_functions().
Using the current CRAN versions of all involved packages (including 'rstanarm' 2.32.2, 'rstan' 2.32.7, 'StanHeaders' 2.39.1),
R CMD checkgives:Unfortunately, the check log is not very helpful, not only because of the 'testthat' camouflage but also because
rstan::expose_stan_functionsrunsRcpp::sourceCpp()intry(silent=TRUE), hiding the actual error. So I insertedjust before the
expose_stan_functionscall in the test script to remove its silence.This reveals that building the shared library
succeeds, but
Rcpp::sourceCpp()then fails from loading the module (source(scriptPath, local = env)):Obviously,
system.file("lib", "libtbb.so", package = "RcppParallel")is available, but not normally in the runtime search path, and there is no system installation of TBB.FWIW, I can make this test compilation work by setting
before
expose_stan_functions().