Skip to content
Latchkey

Cargo "object not found" - Git Dependency Rev Missing in CI

A git = "..." dependency references a branch, tag, or commit that the upstream repo no longer has. Cargo cloned the repo but could not resolve the requested rev, so it cannot pin the dependency.

What this error means

cargo fails updating a git source with failed to find branch/tag/rev or object not found - no match for id. It appears when an upstream force-push, deleted branch, or moved tag removes the commit you depended on.

cargo
error: failed to get `mylib` as a dependency of package `app v0.1.0`

Caused by:
  object not found - no match for id (a1b2c3d4...) ; class=Odb (9)

Common causes

The referenced rev was removed upstream

A force-push, rebased branch, deleted branch, or re-pointed tag means the commit your rev/branch/tag named no longer exists in the remote.

Stale git cache vs. moved tag

A tag that was moved upstream conflicts with a cached clone, so cargo cannot reconcile the requested rev with what it can fetch.

How to fix it

Pin to a commit that still exists

Reference an immutable commit rev rather than a mutable branch or tag.

Cargo.toml
[dependencies]
mylib = { git = "https://github.com/org/mylib", rev = "9f8e7d6" }

Refresh the git source and lock

Force cargo to re-fetch the git source and update the lockfile to a valid rev.

Terminal
rm -rf ~/.cargo/git
cargo update -p mylib

How to prevent it

  • Pin git dependencies to immutable commit revs, not moving branches/tags.
  • Vendor or fork critical git dependencies you cannot control.
  • Commit Cargo.lock so the resolved git rev is reproducible.

Related guides

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