##################################### ## This script will install all the packages listed in the renv.lock file. ## It is different to `renv::restore()`, because it will install the latest available versions of each package, rather than the versions that were used when the lockfile was created ## ## This is equivalent to a 'composer update' in php (while renv::restore() is equivalent to 'composer install'). ## ## Written because `renv::update()` only updates packages that are currently installed, so is not helpful when the versions specified in a lock file no longer install properly. ##################################### install.packages("jsonlite") library(jsonlite) # Load the renv lock file renv_packages <- jsonlite::fromJSON("renv.lock") # get the keys of the list of packages package_names <- names(renv_packages$Packages) # install the packages (this will take a while) install.packages(package_names) # update the .lock file with the latest versions renv::snapshot()