R "there is no package called X" in CI
R could not find the named package in any library on .libPaths(). The package was never installed into the library this R process searches, so library() or require() fails at load time.
What this error means
A script or test fails with "Error in library(X): there is no package called 'X'", even though it loads on a developer machine. The runner used a different library path or never ran the install step.
Error in library(data.table) : there is no package called 'data.table'
Execution haltedCommon causes
The package was never installed on the runner
CI ran Rscript without first installing dependencies, or the install step failed silently, so the library directory has no copy of the package.
Install and run use different .libPaths()
The package was installed into a user library that the test R process does not search, often because R_LIBS_USER differs between steps.
How to fix it
Install dependencies before running
- Add an explicit install step before any script that loads the package.
- Install into the same library the run step uses.
- Re-run so
library()finds the package.
Rscript -e 'install.packages("data.table", repos="https://cloud.r-project.org")'
Rscript -e 'library(data.table)'Restore a renv project library
If the project uses renv, restore the recorded library so every package the lockfile names is present.
Rscript -e 'renv::restore()'How to prevent it
- Install or restore dependencies as a dedicated CI step.
- Keep R_LIBS_USER consistent across install and run steps.
- Cache the R library so installs are not repeated every run.