Skip to content

Packages are not found after R upgrade

Lorenz Walthert edited this page May 19, 2024 · 11 revisions

Here is what you may see

For example if you see

Error in loadNamespace(x) : there is no package called ‘docopt’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

After an R minor or major upgrade, pre-commit may wants to use old and incompatible binaries / installed packages.

What you need to do

You need to destroy the invalid links and let pre-commit link these again with the correct version.

  • run pre-commit clean to delete the pre-commit cache.
  • run pre-commit install --install-hooks
  • try to commit again.
  • if it fails, install the package manually with renv (so it's added to the cache) with renv::install('docopt').
  • try to commit again.

Clone this wiki locally