
Install R dependencies inside a throwaway Docker container
Source:R/reproducibility_check_docker.R
repro_install_deps_docker.RdThe Docker-backed twin of repro_install_deps(): same return contract,
same throwaway-library semantics, but the actual install.packages()/
remotes::install_github() call runs INSIDE a container (default
networking, since CRAN/GitHub must be reachable), writing into lib_dir
via a bind mount — so the run phase (repro_run_scripts_docker()), which
mounts the same lib_dir with the network off, finds the packages already
there.
Usage
repro_install_deps_docker(
install_deps,
lib_dir,
image = "rocker/r-ver:latest",
timeout = 600
)Arguments
- install_deps
a data frame as produced inside
reproducibility_check()(package,source,ref,base) — the non-base rows ofrepro_dependencies()'s output- lib_dir
throwaway library directory ON THE HOST (created if absent); bind-mounted into the container at
/rlib- image
the Docker image to install into (see
.repro_docker_image_for())- timeout
per-package-batch timeout in seconds for the whole install container run (default 600 — installs can be slow, esp. compiling from source)
Value
a data frame with package, source, installed (logical),
message (error text on failure, else ""), via_archive (TRUE when the
package was not on CRAN and came from the CRAN Archive; a package not on
CRAN is first looked for on Bioconductor, see
.repro_docker_elsewhere_lines()),
category (see .repro_classify_install_message(); NA for a
successful install), version_recorded, version_installed and
version_note — same columns as repro_install_deps() so callers
do not need to branch on which backend ran. A row with a version is
treated as there (see repro_install_deps()).
Details
Unlike repro_install_deps(), there is no cran_to_main_lib option: a
container has no access to (and must not be given access to) the host's
real R library, so every install always goes into the throwaway lib_dir.
Examples
if (FALSE) { # \dontrun{
# needs Docker
deps <- repro_dependencies("library(pwr)")
repro_install_deps_docker(deps, file.path(tempdir(), "lib"))
} # }