Skip to content

Commit 8a392e4

Browse files
authored
Pass the current lib paths (#2690)
* Pass the current lib paths * Bump minimum version of pak * Add NEWS bullet * Add a test * Spelling
1 parent a3447b9 commit 8a392e4

8 files changed

Lines changed: 39 additions & 2 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Imports:
2525
lifecycle (>= 1.0.5),
2626
memoise (>= 2.0.1),
2727
miniUI (>= 0.1.2),
28-
pak (>= 0.9.3),
28+
pak (>= 0.9.5),
2929
pkgbuild (>= 1.4.8),
3030
pkgdown (>= 2.2.0),
3131
pkgload (>= 1.5.1),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# devtools (development version)
22

3+
* `install()` uses a new feature of `pak::local_install_deps()` to consider the current `.libPaths()` when resolving dependencies, instead of consulting only `.libPaths()[1]`. This was an unintended behavioral change introduced in 2.5.0 (#2691).
4+
35
# devtools 2.5.1
46

57
* `build_readme()` no longer installs dependencies into the temporary library

R/install.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ install <- function(
8787
withCallingHandlers(
8888
pak::local_install_deps(
8989
pkg$path,
90+
lib = .libPaths(),
9091
upgrade = upgrade,
9192
dependencies = dependencies || isTRUE(build_vignettes)
9293
),
@@ -96,6 +97,7 @@ install <- function(
9697
cli::cat_rule("pak::local_install_deps()", col = "cyan")
9798
pak::local_install_deps(
9899
pkg$path,
100+
lib = .libPaths(),
99101
upgrade = upgrade,
100102
dependencies = dependencies || isTRUE(build_vignettes)
101103
)

man/install.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-install.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ test_that("install reports stages", {
2121
)
2222
})
2323

24+
test_that("install() doesn't reinstall deps already in non-primary libpath", {
25+
skip_on_cran()
26+
27+
pkg <- local_package_copy(test_path("testInstallWithDeps"))
28+
withr::local_temp_libpaths()
29+
tmp_lib <- .libPaths()[1]
30+
31+
install(pkg, reload = FALSE, build = FALSE, quiet = TRUE)
32+
33+
installed <- setdiff(
34+
fs::path_file(fs::dir_ls(tmp_lib, type = "directory")),
35+
"_cache"
36+
)
37+
expect_equal(installed, "testInstallWithDeps")
38+
})
39+
2440
test_that("vignettes built on install", {
2541
skip_on_cran()
2642

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: testInstallWithDeps
2+
Title: Test Package With Dependencies
3+
Version: 0.1.0
4+
Authors@R: person("Test", "User", role = c("aut", "cre"), email = "test@example.com")
5+
Description: Minimal package used to test that devtools::install() does not
6+
reinstall dependencies that are already satisfied in a non-primary library.
7+
License: GPL-2
8+
Imports:
9+
cli
10+
Encoding: UTF-8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
importFrom(cli,cli_abort)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hello <- function(x) {
2+
if (!is.character(x)) {
3+
cli::cli_abort("{.arg x} must be a character string.")
4+
}
5+
paste0("Hello, ", x, "!")
6+
}

0 commit comments

Comments
 (0)