diff --git a/build/build-jasp.sh b/build/build-jasp.sh index a6c2079..12c9c9b 100755 --- a/build/build-jasp.sh +++ b/build/build-jasp.sh @@ -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- 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