I am the maintainer of a package relying on rstan (CRAN - Package gppm). Since a few months, my package does not pass the CRAN tests on Windows anymore, while I did not change it (CRAN Package Check Results for Package gppm).
After looking into this, it seems that rstan::stan_model
is the culprit (I am aware that the recommendation is to not compile models at runtime, but for my package, there seems to be no other way). To demonstrate this, I created an empty package, which contains the following as the only test code.
stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'
mod <- rstan::stan_model(model_code = stancode)
Testing this package on the CRAN windows server via
devtools::install_github("karchjd/test_rstan")
devtools::check_win_release()
#faster alternative: rhub::check(platform="windows-x86_64-release")
leads to
== Failed tests ================================================================
-- Error (test-all.R:3:3): stan_code -------------------------------------------
Error: D:/Compiler/rtools40/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: file230582d7c1e6b.o:file230582d7c1e6b.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[__ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1b): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'D:/Compiler/rtools40/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: file230582d7c1e6b.o:file230582d7c1e6b.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD0Ev[__ZN3tbb10interface623task_scheduler_observerD0Ev]+0x1b): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'D:/Compiler/rtools40/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: file230582d7c1e6b.o:file230582d7c1e6b.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD0Ev[__ZN3tbb10interface623task_scheduler_observerD0Ev]+0x39): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'D:/Compiler/rtools40/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: file230582d7c1e6b.o:file230582d7c1e6b.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[__ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1b): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'D:/Compiler/rtools40/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.3.0/../../../../i686-w64-mingw32/bin/ld.exe: file230582d7c1e6b.o:file230582d7c1e6b.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[__ZN3tbb10interface623task_scheduler_observerD1Ev]+0x39): more undefined references to `tbb::internal::task_scheduler_observer_v3::observe(bool)' followcollect2.exe: error: ld returned 1 exit status
Backtrace:
x
1. \-rstan::stan_model(model_code = stancode) test-all.R:3:2
2. \-rstan:::cxxfunctionplus(...)
3. +-pkgbuild::with_build_tools(...)
4. | \-withr::with_path(rtools_path(), code)
5. | \-base::force(code)
6. \-inline::cxxfunction(...)
7. \-inline:::compileCode(f, code, language = language, verbose = verbose)
-- Error (test-all.R:3:3): stan_code -------------------------------------------
Error: invalid connection
Backtrace:
x
1. \-rstan::stan_model(model_code = stancode) test-all.R:3:2
2. \-rstan:::cxxfunctionplus(...)
3. \-base::sink(type = "output")
[ FAIL 2 | WARN 0 | SKIP 0 | PASS 0 ]
Error: Test failures
The issue seems to be related to Rstan on Windows - #177 by rok_cesnovar, but this has been resolved as far as I understand.
What I don’t understand is why rstan
itself is not failing on CRAN. One explanation could be that rstan_model
is not included in any test or example, which would surprise me. What confuses me further is that rstan_model
works perfectly fine on my Windows 10 machine and a Windows Server 2008 virtual machine I created.
Any suggestions on how to proceed would be highly appreciated.