Skip to content
Latchkey

R "ERROR: dependencies ... are not available" in CI

R tried to install a package but one or more of its Imports/Depends could not be obtained, so it aborts. The named dependencies are missing from the configured repositories or themselves failed to install.

What this error means

install.packages stops with "ERROR: dependencies 'A', 'B' are not available for package 'C'" and leaves the target package uninstalled.

R
ERROR: dependencies 'sp', 'units' are not available for package 'sf'
* removing '/usr/lib/R/site-library/sf'

Common causes

Dependencies are not installed and dependencies=FALSE

Installing without resolving dependencies, or from a repo that lacks them, leaves the named packages absent so the build cannot proceed.

A dependency itself failed to build

A required package failed its own source build (a missing system library), so R reports it as not available to dependents.

How to fix it

Install with dependencies resolved

  1. Call install.packages with dependencies enabled so Imports and Depends are pulled in.
  2. Point at a CRAN mirror that publishes the dependencies.
  3. Re-run and confirm the named packages now install first.
Terminal
Rscript -e 'install.packages("sf", dependencies=TRUE, repos="https://cloud.r-project.org")'

Fix the underlying dependency build

If a dependency fails to compile, install its system libraries first so it builds and becomes available.

Terminal
sudo apt-get install -y libudunits2-dev libgdal-dev

How to prevent it

  • Use dependencies=TRUE so transitive packages are installed.
  • Install system libraries that native dependencies require.
  • Pin a CRAN snapshot so the dependency set is stable.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →