Bundler "git source ... uses the cache" / Missing Git Revision in CI
Bundler keeps a local cache of git-sourced gems and reused a stale or incomplete copy. The locked revision is not present in the cached clone, so Bundler cannot check out the gem.
What this error means
bundle install fails on a git-sourced gem, reporting that the locked revision does not exist in the repository or that the cached git source is incomplete. It often follows a restored cache or a force-pushed branch.
Revision abcdef0 does not exist in the repository
https://github.com/example/widget.git. Maybe you misspelled it?
Git error: command `git reset --hard abcdef0` ... exited with non-zero status.Common causes
Stale git cache missing the locked revision
A cached clone under ~/.bundle/cache or vendor/cache predates the locked SHA (e.g. after a force-push), so the revision Bundler wants is not in the cache.
Partial cache restored in CI
A restored bundle cache without the full git checkout leaves Bundler with an incomplete clone it cannot reset to the locked revision.
How to fix it
Clear the git cache and re-fetch
Remove the cached git source and re-run install so Bundler clones the locked revision fresh.
rm -rf ~/.bundle/cache/git vendor/cache/*.git
bundle installRe-lock to a revision that exists
- If the branch was force-pushed, the locked SHA may be gone - re-run bundle update <gem> to lock a current revision.
- Prefer pinning a tag over a moving branch so the revision is stable.
- Include the full git checkout in the cache key, or do not cache the git source at all.
How to prevent it
- Pin git-sourced gems to tags, not moving branches.
- Cache the complete vendor/bundle (including git checkouts) or none of it.
- Re-lock after a dependency’s branch is force-pushed.