Skip to content

Commit

Permalink
support prompting when using pak (closes #1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed May 22, 2024
1 parent 568e8cc commit 9fd23e5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# renv (development version)

* `renv::install()` now respects the `prompt` parameter when `pak` is enabled,
as via `options(renv.config.pak.enabled = TRUE)`. (#1907)

* Fixed an issue with `renv`'s `pak` integration where `renv` could install the
wrong version of a GitHub package during restore if
`options(renv.config.pak.enabled = TRUE)` was set. (#1883)
Expand Down
2 changes: 1 addition & 1 deletion R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ install <- function(packages = NULL,
# if users have requested the use of pak, delegate there
if (config$pak.enabled() && !recursing()) {
renv_pak_init()
return(renv_pak_install(packages, libpaths, project))
return(renv_pak_install(packages, libpaths, prompt, project))
}

# resolve remotes from explicitly-requested packages
Expand Down
19 changes: 15 additions & 4 deletions R/pak.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ renv_pak_init_impl <- function(stream) {

}

renv_pak_install <- function(packages, library, project) {
renv_pak_install <- function(packages, library, prompt, project) {

pak <- renv_namespace_load("pak")
lib <- library[[1L]]
Expand All @@ -82,12 +82,22 @@ renv_pak_install <- function(packages, library, project) {
else
as.character(packages)

if (length(packages) == 0L)
return(pak$local_install_dev_deps(root = project, lib = lib))
if (length(packages) == 0L) {

result <- pak$local_install_dev_deps(
root = project,
lib = lib,
ask = prompt
)

return(result)

}

pak$pkg_install(
pkg = packages,
lib = lib,
ask = prompt,
upgrade = TRUE
)

Expand All @@ -96,6 +106,7 @@ renv_pak_install <- function(packages, library, project) {
renv_pak_restore <- function(lockfile,
packages = NULL,
exclude = NULL,
prompt = FALSE,
project = NULL)
{
pak <- renv_namespace_load("pak")
Expand Down Expand Up @@ -137,7 +148,7 @@ renv_pak_restore <- function(lockfile,
}

# perform installation
pak$pkg_install(remotes)
pak$pkg_install(remotes, ask = prompt)

# return installed records
records
Expand Down
1 change: 1 addition & 0 deletions R/restore.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ restore <- function(project = NULL,
lockfile = lockfile,
packages = packages,
exclude = exclude,
prompt = prompt,
project = project
)

Expand Down
2 changes: 1 addition & 1 deletion R/update.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ update <- function(packages = NULL,
if (config$pak.enabled() && !recursing()) {
packages <- setdiff(packages, exclude)
renv_pak_init()
return(renv_pak_install(packages, libpaths, project))
return(renv_pak_install(packages, libpaths, prompt, project))
}

# get package records
Expand Down

0 comments on commit 9fd23e5

Please sign in to comment.