Skip to content

Commit 4b3d44a

Browse files
authored
Merge pull request #567 from maxim-belkin/no-missing-dependencies
bin/dependencies.R: handle 'no packages were specified' error
2 parents 50fd61f + 1bad008 commit 4b3d44a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/dependencies.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos", def
55
}
66

77
message("lib paths: ", paste(lib, collapse = ", "))
8-
missing_pkgs <- setdiff(
9-
c("rprojroot", "desc", "remotes", "renv"),
10-
rownames(installed.packages(lib.loc = lib))
11-
)
8+
required_pkgs <- c("rprojroot", "desc", "remotes", "renv")
9+
installed_pkgs <- rownames(installed.packages(lib.loc = lib))
10+
missing_pkgs <- setdiff(required_pkgs, installed_pkgs)
11+
1212
# The default installation of R will have "@CRAN@" as the default repository, which directs contrib.url() to either
1313
# force the user to choose a mirror if interactive or fail if not. Since we are not interactve, we need to force the
1414
# mirror here.
1515
if ("@CRAN@" %in% repos) {
1616
repos <- c(CRAN = "https://cran.rstudio.com/")
1717
}
1818

19-
install.packages(missing_pkgs, lib = lib, repos = repos)
20-
19+
if (length(missing_pkgs) != 0) {
20+
install.packages(missing_pkgs, lib = lib, repos = repos)
21+
}
2122
}
2223

2324
find_root <- function() {

0 commit comments

Comments
 (0)