Skip to content
Latchkey

Bundler "Could not find gem" in CI - Fix Missing Gems

Bundler resolved your Gemfile and could not locate one of the requested gems on any configured source. Almost always a typo, a version that no longer exists, or a private gem on a source you have not declared.

What this error means

bundle install or bundle lock aborts before installing anything, printing that it could not find the gem in the configured rubygems repository or sources. Re-running does not help - the gem genuinely is not on the sources Bundler is searching.

bundler output
Could not find gem 'rails (>= 0)' in rubygems repository
https://rubygems.org/ or installed locally.

The source contains the following gems matching 'rails':
  * rails

Common causes

Misspelled gem name or wrong version

The name in the Gemfile differs from the published gem (rails vs rails), or you pinned a version that was yanked. Bundler often prints a "did you mean" hint with the closest match.

The gem lives on a private source

If the dependency is internal, the default rubygems.org source has nothing. Without a source block or a configured Gemfury/private index, Bundler cannot see it.

A platform-only version that does not exist

A version constraint may have releases for some platforms but not the one resolving, leaving Bundler with no candidate that satisfies the requirement.

How to fix it

Verify the exact name and available versions

Search the real gem name and confirm which versions are published.

Terminal
gem search '^rails$' --remote
gem list --remote rails

Point Bundler at the right source

Scope a private gem to its own source so Bundler knows where to look.

Gemfile
source 'https://rubygems.org'

source 'https://gems.example.com' do
  gem 'your-internal-gem'
end

Re-resolve after fixing the name

Terminal
bundle lock --update
bundle install

How to prevent it

  • Commit Gemfile.lock so CI installs the exact resolved set.
  • Scope private gems to an explicit source block.
  • Pin versions you know are published, not yanked releases.

Related guides

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