R CMD check error loading rstan in Ubuntu using github actions

Continuing the discussion from Using rstan() in R package: Error with R CMD check:

I am running into similar issues as in the linked issue with an R package that has brms, cmdstanr, and rstan in the Suggests but I have not had success with the solution from that topic which involved specifying the R_LIBS env variable in the check.Renviron file. I am opening a new topic because I think this is related to the new version of rstan since R CMD check (local and remote via github actions) were passing on Friday (9/8/2023) before the rstan 2.26 release.

Locally (Ubuntu 22.04) devtools::check and R CMD check work fine with one note about the size of the data and docs directories. When I run R CMD check with github actions it passes on Mac and Windows (same single note as I get locally) but fails on Ubuntu (release and previous version). The error on Ubuntu is coming when I try to load rstan.

Based on the release post I tried adding StanHeaders to the Suggests for the package but that did not change the errors. I am not very well versed in R package conventions and the environment that github actions uses so my apologies if there is an obvious solution I am missing.

I installed the new version of rstan locally on Ubuntu 22.04 without issue:

> library(rstan)
Loading required package: StanHeaders

rstan version 2.26.23 (Stan version 2.26.1)

The last error message from github actions is:

** testing if installed package can be loaded
##[error]Error: package or namespace load failed for ‘rstan’:
.onLoad failed in loadNamespace() for 'rstan', details:
call: NULL
error: SyntaxError: Illegal break statement
##[error]Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/tmp/RtmpZ70aM8/pkg-lib13f523c9e348/rstan’
 ---
Backtrace:
1. pak::lockfile_install(".github/pkg.lock")
2. pak:::remote(function(...) { …
3. err$throw(res$error)
 ---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("lockfile_install_internal", asNamespace("pak"))(...)
3. plan$install()
4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
5. base::withCallingHandlers({ …
6. pkgdepends:::handle_events(state, events)
7. pkgdepends:::handle_event(state, i)
8. pkgdepends:::stop_task(state, worker)
9. pkgdepends:::stop_task_build(state, worker)
10. base::throw(new_pkg_build_error("Failed to build source package {pkg}", …
11. | base::signalCondition(cond)
12. global (function (e) …
Execution halted
##[error]Process completed with exit code 1.

I would guess that github actions is relying on cached package installations and has not fully updated to the new versions of rstan and StanHeaders. There is a way to clear the cache on github and re-run the action, which has sometimes helped me. It also sometimes helps me to wait a few days, then the action starts working again. I think this happens because the action eventually gets triggered to install new package versions, or a package server that happened to be down the last time you ran the action is now up again. In general, if you are passing checks locally and your github actions recently worked, I find that it is not a good use of time to try to fix a failed github action. It usually resolves itself, eventually.

3 Likes

You’re definitely right that there are better uses of time than trying to force github actions to work and I appreciate your insight on the caching, it looks like that is correct. Thank you!

3 Likes