set CRAN url if default is "@CRAN@"
authorZhian N. Kamvar <zkamvar@gmail.com>
Wed, 2 Dec 2020 17:35:13 +0000 (09:35 -0800)
committerFrançois Michonneau <francois.michonneau@gmail.com>
Thu, 3 Dec 2020 14:49:03 +0000 (15:49 +0100)
This will fix #526

bin/dependencies.R

index ad5afe78d1d4e88edcc860544fa1fa59db6043f1..640b3e248983fd57b4be98b4e6c2b0bd846c5ce7 100644 (file)
@@ -9,6 +9,12 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos", def
     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)