From d21d90e8eac79f08ff2654ceb9d283009eae7bac Mon Sep 17 00:00:00 2001 From: Mark Colley <39366189+M-Colley@users.noreply.github.com> Date: Tue, 24 Nov 2026 16:22:34 +0000 Subject: [PATCH] Correct the update_packages deprecation guidance Fixes #2709. --- NEWS.md | 2 ++ R/remotes.R | 14 ++++++++++++-- man/install-deprecated.Rd | 8 +++++++- tests/testthat/_snaps/remotes.md | 9 +++++++++ tests/testthat/test-remotes.R | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6e915f3a7..cb7d8be8e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ * `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). * `check_built()` no longer prints `R_CHECK_` check env variables - now handled by `rcmdcheck::rcmdcheck()` directly as of r-lib/rcmdcheck#237 (#2621) +* `update_packages()` now recommends `remotes::update_packages()`, which checks installed packages for updates when called without arguments (@M-Colley, #2709). + # devtools 2.5.2 * `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). diff --git a/R/remotes.R b/R/remotes.R index d57abeb5d..475592a27 100644 --- a/R/remotes.R +++ b/R/remotes.R @@ -23,11 +23,17 @@ #' | `install_svn("url")` | `remotes::install_svn("url")` | #' | `install_url("url")` | `pak::pak("url::url")` | #' | `install_version("pkg", "1.0.0")` | `pak::pak("pkg@1.0.0")` | -#' | `update_packages("pkg")` | `pak::pak("pkg")` | +#' | `update_packages()` | `remotes::update_packages()` | +#' | `update_packages("pkg")` | `remotes::update_packages("pkg")` | #' | `dev_package_deps()` | `pak::local_dev_deps()` | #' | `github_pull("123")` | `remotes::github_pull("123")` | #' | `github_release()` | `remotes::github_release()` | #' +#' With no arguments, `remotes::update_packages()` checks installed packages for +#' updates. Use `pak::pak("pkg")` to install or update a named package from a +#' configured source. Use `pak::pak()` to install or update the current package +#' project's development dependencies. +#' #' @name install-deprecated #' @keywords internal NULL @@ -147,7 +153,11 @@ install_version <- function(...) { #' @rdname install-deprecated #' @export update_packages <- function(...) { - lifecycle::deprecate_warn("2.5.0", "update_packages()", "pak::pak()") + lifecycle::deprecate_warn( + "2.5.0", + "update_packages()", + "remotes::update_packages()" + ) check_installed("remotes") pkgbuild::with_build_tools(remotes::update_packages(...), required = FALSE) } diff --git a/man/install-deprecated.Rd b/man/install-deprecated.Rd index 6585e4c08..3983ab66d 100644 --- a/man/install-deprecated.Rd +++ b/man/install-deprecated.Rd @@ -69,12 +69,18 @@ old remotes functions directly. \code{install_svn("url")} \tab \code{remotes::install_svn("url")} \cr \code{install_url("url")} \tab \code{pak::pak("url::url")} \cr \code{install_version("pkg", "1.0.0")} \tab \code{pak::pak("pkg@1.0.0")} \cr - \code{update_packages("pkg")} \tab \code{pak::pak("pkg")} \cr + \code{update_packages()} \tab \code{remotes::update_packages()} \cr + \code{update_packages("pkg")} \tab \code{remotes::update_packages("pkg")} \cr \code{dev_package_deps()} \tab \code{pak::local_dev_deps()} \cr \code{github_pull("123")} \tab \code{remotes::github_pull("123")} \cr \code{github_release()} \tab \code{remotes::github_release()} \cr } + +With no arguments, \code{remotes::update_packages()} checks installed packages for +updates. Use \code{pak::pak("pkg")} to install or update a named package from a +configured source. Use \code{pak::pak()} to install or update the current package +project's development dependencies. } } \keyword{internal} diff --git a/tests/testthat/_snaps/remotes.md b/tests/testthat/_snaps/remotes.md index b0498ea13..712bc598b 100644 --- a/tests/testthat/_snaps/remotes.md +++ b/tests/testthat/_snaps/remotes.md @@ -13,3 +13,12 @@ `github_release()` was deprecated in devtools 2.5.0. i Please use `remotes::github_release()` instead. +# update_packages() recommends remotes for installed packages + + Code + withRestarts(update_packages(), skip_package_update = function() invisible(NULL)) + Condition + Warning: + `update_packages()` was deprecated in devtools 2.5.0. + i Please use `remotes::update_packages()` instead. + diff --git a/tests/testthat/test-remotes.R b/tests/testthat/test-remotes.R index 499ae9fce..f4572c74b 100644 --- a/tests/testthat/test-remotes.R +++ b/tests/testthat/test-remotes.R @@ -4,3 +4,17 @@ test_that("github_ functions are deprecated", { . <- github_release() }) }) + +test_that("update_packages() recommends remotes for installed packages", { + withr::local_options(lifecycle_verbosity = "warning") + local_mocked_bindings( + check_installed = function(...) invokeRestart("skip_package_update") + ) + + expect_snapshot( + withRestarts( + update_packages(), + skip_package_update = function() invisible(NULL) + ) + ) +})