Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pkg_upgrade() #289

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add pkg_upgrade() #289

wants to merge 4 commits into from

Conversation

gaborcsardi
Copy link
Member

No description provided.

@gaborcsardi gaborcsardi mentioned this pull request Apr 12, 2021
7 tasks
@jimhester
Copy link
Member

Should there be a helper to upgrade all installed packages, equivalent to upgrade.packages()? Or maybe a lib_upgrade() to upgrade all the packages in a library?

@gaborcsardi
Copy link
Member Author

Should there be a helper to upgrade all installed packages, equivalent to upgrade.packages()? Or maybe a lib_upgrade() to upgrade all the packages in a library?

There will be a lib_upgrade() (see #168). But that is harder to implement in a useful way, because of the possible conflicts.

@torfason
Copy link

torfason commented Feb 8, 2022

I'd like to cheer on this pull request, and second the suggestion that there be a helper function to upgrade all packages. For someone who is not deep into the internals of pak it is not very clear whether using update.packages() would mess with all the benefits of pak (such as caching and dependency resolution), or even break things. It would really ease adoption to be able to switch completely, rather than using a mixture of both (assuming one wants to keep up to date with package development in general).

@gaborcsardi
Copy link
Member Author

would mess with all the benefits of pak (such as caching and dependency resolution), or even break things.

No, it will not break anything.

@torfason
Copy link

torfason commented Feb 9, 2022

Awesome, thanks for the quick reply. Great that it won't break anything, but I am assuming that it will not give all the benefits either, such as keeping the downloaded packages to prevent redownloading on a second install (such as for a check).

So I put together a quick and dirty shim to query old packages on the fly and then install the most recent version with pak:

update.packages <- function(...) {
  cat("Using old.packages() and pak() to update packages ...\n")
  d.outdated <- old.packages() |> tibble::as_tibble()
  if (nrow(d.outdated)>0) {
    pak::pak(d.outdated$Package)
  } else {
    cat("No outdated packages found.\n")
  }
}

I realize that this is by no means the same as having a real pkg_upgrade() but thought of it as a helpful standin in the meantime.

In particular, this does not pick up outdated packages on GitHub and such, but it does add a freshly installed package to pak's cache, and on a quick test, seems to work well. Of course, not everyone might like the shadowing of the native update.packages(), but anyone interested in this approach could easily rename the function to something else.

@mcanouil
Copy link

mcanouil commented Feb 26, 2022

Indeed, such function could be really useful.
For now, I am using a one-line command with VSCode keybinding.

if (length(pkgs <- setdiff(rownames(old.packages()), "pak")) > 0) pak::pkg_install(pkgs)

@batpigandme
Copy link

Yay for this FR—I assume it's the same as what I was coming to request, which is an equivalent to remotes::update_packages().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants