permissive checks for pre-alpha lessons
[rnaseq-cwl-training.git] / bin / dependencies.R
index 676b05055cdbcd29f654e097a55d3020a406c927..640b3e248983fd57b4be98b4e6c2b0bd846c5ce7 100644 (file)
@@ -1,4 +1,4 @@
-install_required_packages <- function(lib = NULL, repos = getOption("repos")) {
+install_required_packages <- function(lib = NULL, repos = getOption("repos", default = c(CRAN = "https://cran.rstudio.com/"))) {
 
   if (is.null(lib)) {
     lib <- .libPaths()
@@ -9,6 +9,12 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos")) {
     c("rprojroot", "desc", "remotes", "renv"),
     rownames(installed.packages(lib.loc = lib))
   )
+  # The default installation of R will have "@CRAN@" as the default repository, which directs contrib.url() to either
+  # force the user to choose a mirror if interactive or fail if not. Since we are not interactve, we need to force the
+  # mirror here.
+  if ("@CRAN@" %in% repos) {
+    repos <- c(CRAN = "https://cran.rstudio.com/")
+  }
 
   install.packages(missing_pkgs, lib = lib, repos = repos)