It is best to restart the R session prior to performing these upgrades, as loaded packages can often prevent successful upgrades. One fix is to upgrade all of the packages used in your project. This occurs because package upgrades can leave your project library in an inconsistent state.
What if an upgrade breaks code?Ī common problem after upgrading packages is to hit an error running the library statements in your code. Organizations can use tools like Package Manager to make multiple versions of private packages available. For public packages, CRAN provides these older versions in the CRAN archive. The safety net provided by the renv package relies on access to older versions of R packages. # use this function to view the history of your lockfile renv :: history() # if an upgrade goes astray, revert the lockfile renv :: revert( commit = "abc123") # and restore the previous environment renv :: restore() This type of isolation is accomplished by creating per-project libraries. By isolating projects, you can ensure that upgrading the packages for one project won’t break code in other projects. The first concern for safe upgrades is project isolation. We also present troubleshooting tips for cases where upgrading a package breaks code. Keep in mind that the other strategies promote safe package upgrades as well. This page describes the Snapshot and Restore strategy with an emphasis on package upgrades. They provide a safety net in case you need to roll back a change.Specifically, there are two ways reproducible environments support package upgrades: Luckily, the strategies for reproducible environments can make package upgrades safe. For example, the upgrade broke part of their code, or upgrading a package for one project accidentally broke the code in another project. Most R users have been in a situation where upgrading a package had unintended consequences. Upgrading packages can be a risky affair.