
Install a paper's declared dependencies into a throwaway library
Source:R/reproducibility_check.R
repro_install_deps.RdInstalls each non-base dependency into lib_dir (a temp library, never the
user's), so a run does not mutate the user's installed packages. CRAN packages
come from install.packages(); Bioconductor packages (source == "bioc",
see repro_dependencies()/.repro_bioc_packages()) from
BiocManager::install(), installing BiocManager itself first if absent;
GitHub/URL sources from the ref the code named
(remotes::install_github() / install.packages(url)), honouring a pinned
@ref when present. Every install's outcome is recorded; installing runs
package build/configure scripts, so this is part of the gated execute phase.
Arguments
- install_deps
the module's
install_depsframe (package,source,ref, and optionallyversion, from.repro_recorded_plan()), base packages already excluded- lib_dir
the throwaway library path (created if absent); ignored for CRAN-source packages when
cran_to_main_lib = TRUE(see below)- cran_to_main_lib
if
TRUE, CRAN-source packages are installed into your DEFAULT library (nolibargument — same as callinginstall.packages(pkg)yourself) instead of the throwawaylib_dir, and so PERSIST after the run rather than being deleted with the sandbox. This trades a one-time, permanent change to your R library for install work that is shared across every later call needing the same package (useful whenreproducibility_check()runs across many papers in one session/script: a CRAN package installed for an early paper is already present, and skipped as already-installed, for every later one). GitHub/URL sources are deliberately excluded from this and always go into the throwawaylib_dirregardless of this argument — those are arbitrary, unreviewed code you likely do not want permanently in your main library. DefaultFALSE(everything throwaway, the original behaviour).A CRAN-source package that
install.packages()cannot find is not necessarily a broken dependency: CRAN removes (archives) packages that stop passing its checks, but every version ever published stays available as a source tarball under the CRAN Archive (https://cran.r-project.org/src/contrib/Archive/<pkg>/). When the live-CRAN install fails, this retries once from the Archive's most recent version before giving up — a package the paper's authors could install at the time (and that later dropped off live CRAN) still installs, instead of the run recording an "errored" script for a cause that has nothing to do with the paper's code. The retry is recorded invia_archiveso the report can say the run used a stale-but-real version rather than the one the authors had.- deadline
the time (
Sys.time()plus the time for installing) after which no further package is started;NULL(the default) sets no limit
Value
a data frame with package, source, installed (logical),
message (error text on failure, else ""), via_archive (logical,
TRUE when installed from the CRAN Archive after a live-CRAN failure),
category (see .repro_classify_install_message(); NA for a
successful install), version_recorded (the version asked for, or NA),
version_installed (the version now in the libraries, or NA) and
version_note (why the recorded version was not installed, else "").
Details
A row with a version is installed at that version with
remotes::install_version(), unless the libraries already hold it; packages
it depends on that are not there yet get their current version. When that
version cannot be installed, the current version is installed instead and
version_note says why. Such a row always goes into the throwaway lib_dir,
so an old version can never replace one in your own library. A Bioconductor
package always gets its current version, since Bioconductor versions follow
the R version.
Examples
if (FALSE) { # \dontrun{
# installs packages into a throwaway library
deps <- repro_dependencies("library(pwr)")
repro_install_deps(deps, file.path(tempdir(), "lib"))
} # }