Skip to content

Commit 1bad008

Browse files
committed
bin/dependencies.R: handle 'no packages were specified' error
Fixes the following issue: ``` $ make site lib paths: /Library/Frameworks/R.framework/Versions/3.5/Resources/library Error in install.packages(missing_pkgs, lib = lib, repos = repos) : no packages were specified Calls: install_required_packages -> install.packages Execution halted make: *** [install-rmd-deps] Error 1 ```
1 parent 50fd61f commit 1bad008

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)