Skip to content

Commit

Permalink
Fix webr::install() when using a lib argument
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
georgestagg committed Jun 17, 2024
1 parent 40c06d0 commit d838151
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/webr/R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d838151

Please sign in to comment.