Recover from interrupted R installs before building modules

The seven-module build stalled at 6/7 on all three passes, deterministically,
with a cause unrelated to jaspMixedModels itself:

  ERROR: failed to lock directory '.../LibraryR' for modifying
  Error in library("devtools") : there is no package called 'devtools'

R leaves 00LOCK-<pkg> directories behind when an install is interrupted and
then refuses to modify the library at all, and the interrupted install had
also taken devtools with it. Every one of my killed containers poisoned the
library for the runs after it.

Clear stale locks and reinstall whatever is missing before building, rather
than assuming a clean library. This matters for the pipeline too: a job that
times out or gets OOM-killed would otherwise leave the runner unable to
build until someone cleaned up by hand.
This commit is contained in:
agw
2026-09-02 22:40:00 +02:00
parent e49be3dfa4
commit 62ce2a60c7
+24
View File
@@ -268,6 +268,30 @@ PY
# with less parallelism than the C++ build uses.
R_JOBS="${R_JOBS:-2}"
export MAKEFLAGS="-j${R_JOBS}"
# R leaves 00LOCK-<pkg> directories behind when an install is interrupted, and
# refuses to touch the library afterwards ("failed to lock directory ... for
# modifying"). A build that is killed mid-install - a timeout, an OOM, a stopped
# container - therefore poisons the library for every later run.
log "clearing stale R install locks"
rm -rf "${MODULE_LIBRARY}"/00LOCK-* 2>/dev/null || true
# The interrupted install can also leave the library without devtools, which
# buildModuleBundlesLocally.R calls unconditionally. Reinstall whatever is
# missing rather than assuming a clean slate.
Rscript -e "
lib <- '${MODULE_LIBRARY}'
dir.create(lib, recursive = TRUE, showWarnings = FALSE)
.libPaths(new = lib)
for (pkg in c('remotes', 'devtools')) {
if (!requireNamespace(pkg, lib.loc = lib, quietly = TRUE)) {
message('installing missing ', pkg)
install.packages(pkg, lib = lib, repos = 'https://cran.r-project.org')
}
if (!requireNamespace(pkg, lib.loc = lib, quietly = TRUE))
stop('failed to install ', pkg)
}
"
log "compiling R packages with -j${R_JOBS} (OpenMx needs the headroom)"
# Build only the modules JASP actually ships. Modules/modules-settings.json