From 2fd5688447492bdb24c7615b6e34e8ec61bf72d8 Mon Sep 17 00:00:00 2001 From: Fabian Distler Date: Wed, 2 Sep 2026 21:28:31 +0200 Subject: [PATCH 1/3] fix: fix ignored deps install fixes #2702 --- R/install.R | 2 +- R/sitrep.R | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/R/install.R b/R/install.R index 896f36d37..e51d0d920 100644 --- a/R/install.R +++ b/R/install.R @@ -277,7 +277,7 @@ local_install <- function( report_deps_ahead_behind( dep_status, pkg_name = pkg$package, - update_code = "pak::local_install_dev_deps()" + install_code = "pak::local_install_dev_deps()" ) if (!quiet) { diff --git a/R/sitrep.R b/R/sitrep.R index 7ee17dd67..7113f7566 100644 --- a/R/sitrep.R +++ b/R/sitrep.R @@ -215,7 +215,8 @@ print.dev_sitrep <- function(x, ...) { report_deps_ahead_behind( x$devtools_deps, pkg_name = "devtools", - update_code = 'pak::pak("devtools")' + install_code = 'pak::pak("devtools")', + upgrade_code = 'pak::pak("devtools", upgrade = TRUE)' ) } @@ -229,7 +230,7 @@ print.dev_sitrep <- function(x, ...) { report_deps_ahead_behind( x$pkg_deps, pkg_name = x$pkg$package, - update_code = "pak::local_install_dev_deps()" + install_code = "pak::local_install_dev_deps()" ) } @@ -297,16 +298,22 @@ pkg_dep_status <- function(pkg, dependencies = NA) { #' @param dep_status A data frame as returned by `compare_deps()`, with #' columns `package`, `latest`, `installed`, `status`. #' @param pkg_name Package name to mention in the message. -#' @param update_code Code suggestion for updating behind deps. +#' @param install_code Code suggestion for installing missing deps. +#' @param upgrade_code Code suggestion for updating behind deps. #' @return Called for its side effects. #' @noRd -report_deps_ahead_behind <- function(dep_status, pkg_name, update_code) { +report_deps_ahead_behind <- function( + dep_status, + pkg_name, + install_code, + upgrade_code = install_code +) { missing <- dep_status[dep_status$status == "missing", ] if (nrow(missing) > 0) { n <- nrow(missing) cli::cli_bullets(c( "!" = "{n} {.field {pkg_name}} {cli::qty(n)}{?dependency is/dependencies are} not installed.", - " " = "Install {cli::qty(n)}{?it/them} with {.run {update_code}}." + " " = "Install {cli::qty(n)}{?it/them} with {.run {install_code}}." )) cli::cli_verbatim(paste(" ", dep_labels(missing))) } @@ -316,7 +323,7 @@ report_deps_ahead_behind <- function(dep_status, pkg_name, update_code) { n <- nrow(behind) cli::cli_bullets(c( "!" = "{n} {.field {pkg_name}} {cli::qty(n)}{?dependency is/dependencies are} out of date.", - " " = "Update {cli::qty(n)}{?it/them} with {.run {update_code}}." + " " = "Update {cli::qty(n)}{?it/them} with {.run {upgrade_code}}." )) cli::cli_verbatim(paste(" ", dep_labels(behind))) } From e33f7d5c0b019135f54f201c1ce376d588e1d078 Mon Sep 17 00:00:00 2001 From: Fabian Distler Date: Wed, 2 Sep 2026 21:29:02 +0200 Subject: [PATCH 2/3] docs: add news entry for #2702 --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 03da4ddb6..fbb673874 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # devtools (development version) +* `dev_sitrep()` now suggests `pak::pak("devtools", upgrade = TRUE)` for dependencies that are out of date, because the previously suggested `pak::pak("devtools")` does not upgrade dependencies that are already installed and therefore left the report unchanged (#2702). * `submit_cran()` gives a more informative error when the CRAN submission form can't be used, suggesting that the user consult to see if there's a CRAN closure (#2700). # devtools 2.5.2 From 34a78313f0a4a30ff9c7068d0640b227fa762d3c Mon Sep 17 00:00:00 2001 From: Fabian Distler Date: Wed, 2 Sep 2026 21:41:08 +0200 Subject: [PATCH 3/3] tests: add tests for the dev_siterep fix --- tests/testthat/_snaps/sitrep.md | 22 +++++++++++++++++++++- tests/testthat/test-sitrep.R | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/testthat/_snaps/sitrep.md b/tests/testthat/_snaps/sitrep.md index b32f256a7..9a86b8238 100644 --- a/tests/testthat/_snaps/sitrep.md +++ b/tests/testthat/_snaps/sitrep.md @@ -71,7 +71,7 @@ -- devtools ------------------------------------------------ * version: 2.4.6 ! 1 devtools dependency is out of date. - Update it with `pak::pak("devtools")`. + Update it with `pak::pak("devtools", upgrade = TRUE)`. cli (behind: 0.5.0 vs 1.0.0) -- dev package --------------------------------------------- * package: @@ -94,6 +94,26 @@ * package: * path: +# print suggests upgrade = TRUE only for out-of-date deps + + Code + print(x) + Message + -- R ------------------------------------------------------- + * version: 4.4.0 + * path: '/usr/lib/R' + -- devtools ------------------------------------------------ + * version: 2.4.6 + ! 1 devtools dependency is not installed. + Install it with `pak::pak("devtools")`. + rlang (missing) + ! 1 devtools dependency is out of date. + Update it with `pak::pak("devtools", upgrade = TRUE)`. + cli (behind: 0.5.0 vs 1.0.0) + -- dev package --------------------------------------------- + * package: + * path: + # print notes dev versions of devtools deps Code diff --git a/tests/testthat/test-sitrep.R b/tests/testthat/test-sitrep.R index 5d64a9d32..7f206be58 100644 --- a/tests/testthat/test-sitrep.R +++ b/tests/testthat/test-sitrep.R @@ -73,6 +73,22 @@ test_that("print warns about missing devtools deps", { expect_snapshot(print(x)) }) +test_that("print suggests upgrade = TRUE only for out-of-date deps", { + local_reproducible_output(width = 60) + x <- new_dev_sitrep( + r_version = R_system_version("4.4.0"), + r_path = "/usr/lib/R", + devtools_version = package_version("2.4.6"), + devtools_deps = data.frame( + package = c("rlang", "cli"), + latest = c("1.0.0", "1.0.0"), + installed = c(NA_character_, "0.5.0"), + status = c("missing", "behind") + ) + ) + expect_snapshot(print(x)) +}) + test_that("print notes dev versions of devtools deps", { local_reproducible_output(width = 60) x <- new_dev_sitrep(