From d8381511c88b6589ccfe72e2db25a0023a302c04 Mon Sep 17 00:00:00 2001 From: George Stagg Date: Mon, 17 Jun 2024 13:54:25 +0100 Subject: [PATCH] Fix webr::install() when using a lib argument The `find.packages()` function used as part of the webr::install() process did not take into account the `lib` argument. Now, packages are skipped if they are found in `.libPaths()` or in the non-NULL `lib` argument. --- packages/webr/R/install.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/webr/R/install.R b/packages/webr/R/install.R index 9353e5d7..7a55cb3f 100644 --- a/packages/webr/R/install.R +++ b/packages/webr/R/install.R @@ -37,15 +37,18 @@ install <- function(packages, deps <- unlist(tools::package_dependencies(packages, info), use.names = FALSE) deps <- unique(deps) + # Search for existing packages in `.libPaths()` and the `lib` argument + lib_loc <- c(lib, .libPaths()) + for (dep in deps) { - if (length(find.package(dep, quiet = TRUE))) { + if (length(find.package(dep, lib.loc = lib_loc, quiet = TRUE))) { next } install(dep, repos, info, lib, quiet, mount) } for (pkg in packages) { - if (length(find.package(pkg, quiet = TRUE))) { + if (length(find.package(pkg, lib.loc = lib_loc, quiet = TRUE))) { next }