From 403f070fd5c3ab5d7c3093230be1abaab78023c3 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Thu, 30 Apr 2026 09:06:19 -0700 Subject: [PATCH] Make sure cli is installed in `.libPaths()[2]` --- tests/testthat/test-install.R | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-install.R b/tests/testthat/test-install.R index d557ca07b..5cf7137e2 100644 --- a/tests/testthat/test-install.R +++ b/tests/testthat/test-install.R @@ -21,10 +21,26 @@ test_that("install reports stages", { ) }) -test_that("install() doesn't reinstall deps already in non-primary libpath", { +test_that("install() doesn't reinstall deps that are already installed", { skip_on_cran() pkg <- local_package_copy(test_path("testInstallWithDeps")) + + # Install cli into a temp lib via pak, to make extra sure that + # pak considers it already satisfied when install() runs. + withr::local_temp_libpaths() + + # It's very hard to silence pak. + local({ + withr::local_output_sink(withr::local_tempfile()) + withr::local_message_sink(withr::local_tempfile()) + withCallingHandlers( + pak::pkg_install("cli", lib = .libPaths()[1], ask = FALSE), + callr_message = function(cnd) tryInvokeRestart("muffleMessage") + ) + }) + + # Prepend a second temp lib in which to install the in-development package. withr::local_temp_libpaths() tmp_lib <- .libPaths()[1]