Skip to content
Latchkey

Cargo "failed to load source for dependency" in CI

failed to load source for dependency X means Cargo knew where to look for a dependency but could not open that source at all - a path that doesn’t exist, a git remote it can’t reach, or a registry it can’t read.

What this error means

cargo aborts resolution with failed to load source for dependency <crate>, usually followed by a Caused by: line naming the bad path, URL, or registry. Nothing builds because the source itself can’t be opened, not merely a version within it.

cargo output
error: failed to load source for dependency `shared`

Caused by:
  Unable to update /home/runner/work/app/../shared

Caused by:
  failed to read `/home/runner/work/app/../shared/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

Common causes

A path dependency points nowhere

A path = "../shared" entry resolves to a directory that doesn’t exist on the runner - often because a workspace member moved, or the checkout didn’t include a sibling repo.

A git or registry source is unreachable

A git = "..." remote or a custom registry index can’t be reached or read, so Cargo can’t load any versions from it.

How to fix it

Verify the path resolves on the runner

Path dependencies are relative to the crate’s Cargo.toml. Confirm the target exists in the CI checkout, not just locally.

Cargo.toml
[dependencies]
shared = { path = "../shared" }   # must exist relative to this Cargo.toml

Read the Caused-by chain for the real source

  1. Scroll to the deepest Caused by: line - it names the path, git URL, or registry that failed.
  2. For a git source, confirm the URL and that credentials are present.
  3. For a registry, confirm the index is configured in .cargo/config.toml.

How to prevent it

  • Keep workspace member and path-dependency directories accurate after moves.
  • Check out sibling repos that path dependencies point at in CI.
  • Declare git and registry sources explicitly so Cargo knows where to load from.

Related guides

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