Skip to content

Commit

Permalink
Merge pull request #567 from maxim-belkin/no-missing-dependencies
Browse files Browse the repository at this point in the history
bin/dependencies.R: handle 'no packages were specified' error
  • Loading branch information
zkamvar authored Mar 29, 2021
2 parents 50fd61f + 1bad008 commit 4b3d44a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bin/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos", def
}

message("lib paths: ", paste(lib, collapse = ", "))
missing_pkgs <- setdiff(
c("rprojroot", "desc", "remotes", "renv"),
rownames(installed.packages(lib.loc = lib))
)
required_pkgs <- c("rprojroot", "desc", "remotes", "renv")
installed_pkgs <- rownames(installed.packages(lib.loc = lib))
missing_pkgs <- setdiff(required_pkgs, installed_pkgs)

# 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)

if (length(missing_pkgs) != 0) {
install.packages(missing_pkgs, lib = lib, repos = repos)
}
}

find_root <- function() {
Expand Down

0 comments on commit 4b3d44a

Please sign in to comment.