Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update all packages from GitHub

Tags:

I know you can install packages from CRAN with this syntax:

install.packages(c("Rcpp"), dependencies=TRUE) 

You can update all of them from CRAN with:

update.packages() 

On the other side, you can install packages (compiling them) from GitHub with:

install_github("hadley/tidyr") 

How can you upgrade all GitHub packages?

I mean without reinstalling (and compiling) them one at a time. Something like update.packages() for github.

like image 618
skan Avatar asked Sep 12 '15 11:09

skan


People also ask

How do I update RENV?

You can call renv::update() with no arguments to update all packages within the project, excluding any packages ignored via the ignored.

What is a package update?

Package updates provide fixes and updates to installed product packages. You can use the Update wizard in IBM® Installation Manager to install updates for product packages that were installed with IBM Installation Manager.

What is GitHub packages storage?

GitHub Packages is a platform for hosting and managing packages, including containers and other dependencies. GitHub Packages combines your source code and packages in one place to provide integrated permissions management and billing, so you can centralize your software development on GitHub.


2 Answers

This works for me. It goes through all of the packages in your library, not only loaded packages.

update_github_pkgs <- function() {    # check/load necessary packages   # devtools package   if (!("package:devtools" %in% search())) {     tryCatch(require(devtools), error = function(x) {warning(x); cat("Cannot load devtools package \n")})     on.exit(detach("package:devtools", unload=TRUE))   }    pkgs <- installed.packages(fields = "RemoteType")   github_pkgs <- pkgs[pkgs[, "RemoteType"] %in% "github", "Package"]    print(github_pkgs)   lapply(github_pkgs, function(pac) {     message("Updating ", pac, " from GitHub...")      repo = packageDescription(pac, fields = "GithubRepo")     username = packageDescription(pac, fields = "GithubUsername")      install_github(repo = paste0(username, "/", repo))   }) } 
like image 89
vh-d Avatar answered Sep 18 '22 09:09

vh-d


library(devtools)  #' Update all github installed packages. #' #' This will trash any non-master branch installs, and spend time re-installing #' packages which are already up-to-date. update_github <- function() {   pkgs = loadedNamespaces()   print(pkgs)   desc <- lapply(pkgs, packageDescription, lib.loc = NULL)   for (d in desc) {     message("working on ", d$Package)     if (!is.null(d$GithubSHA1)) {       message("Github found")       install_github(repo = d$GithubRepo, username = d$GithubUsername)     }   } }  # test it: # install github version of tidyr install_github("hadley/tidyr") library(tidyr) update_github() 

Don't run this if you have any github installations from anything more complicated than the master branch of user/repo. Also be careful if you have a lot of github installations, since this will blindly reinstall them all, even if up-to-date. This could take a long time, and also might break working packages if github master branches are not in tip top condition.

Take a look at devtools R/session_info.r for details.

like image 39
Jack Wasey Avatar answered Sep 20 '22 09:09

Jack Wasey