Bundler: Could not find gem in locally installed gems Ruby / Rails Origin: Application & API Last updated 5 Nov 2026

Bundler: Could not find gem 'rails (~> 7.1)' in locally installed gems / Could not find rails-7.1.0 in any of the gem sources listed in your Gemfile

A gem from the Gemfile/Gemfile.lock isn't installed (or isn't available at that version).

Exact message you may see Bundler::GemNotFound: Could not find gem 'rails (~> 7.1)' in locally installed gemsCould not find rails-7.1.0 in any of the gem sources listed in your GemfileCould not find gem 'x' in any of the gem sources listed in your GemfileRun `bundle install` to install missing gemsBundler could not find gem
Seen on: Ruby

Meaning

Run bundle install. If it still fails: the version may be yanked, the source (private gem server) unreachable/auth missing (bundle config), the platform lock missing (bundle lock --add-platform x86_64-linux), or the Ruby version doesn't satisfy the gem. In Docker/CI, run install in the same image and cache properly.

Common causes

  • bundle install not run in this environment
  • Gem version yanked/unavailable
  • Private source credentials missing
  • Platform mismatch in Gemfile.lock (arm64 vs linux)
  • Ruby version doesn't meet the gem's requirement

⚡ Quick fix

  1. bundle install
  2. bundle lock --add-platform x86_64-linux for CI/Docker
  3. Configure credentials: bundle config set --global https://gems.example.com user:token

Detailed fix by platform

Ruby

  1. bundle check; bundle install --jobs 4

How to diagnose

  1. Install — Run?
  2. Platform — Locked?
  3. Source — Reachable/auth?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

ArgumentError: missing keyword / unknown keyword — Ruby: ArgumentError: missing keyword: :name / unknown keyword: :nmae (Ruby / Rails)ArgumentError: missin…ArgumentError: wrong number of arguments (given 1, expected 2) — Ruby: ArgumentError: wrong number of arguments (given 1, expected 2..3) (Ruby / Rails)ArgumentError: wrong …Bundler could not find compatible versions for gem — Bundler: Bundler could not find compatible versions for gem "activesupport": In Gemfile: rails (= 7.1.0) depends on activesupport (= 7.1.0) (Ruby / Rails)Bundler could not fin…FactoryBot::DuplicateDefinitionError: Factory already registered — FactoryBot: FactoryBot::DuplicateDefinitionError: Factory already registered: user (Ruby / Rails)FactoryBot::Duplicate…Failed to build gem native extension — Ruby: ERROR: Failed to build gem native extension. current directory: /gems/pg-1.5.4/ext/pg — An error occurred while installing pg (Ruby / Rails)Failed to build gem n…FrozenError: can't modify frozen String — Ruby: FrozenError: can't modify frozen String: "abc" (Ruby / Rails)FrozenError: can't mo…LoadError: cannot load such file — Ruby: LoadError: cannot load such file -- nokogiri (or: cannot load such file -- bundler/setup) (Ruby / Rails)LoadError: cannot loa…Nokogiri: could not find a platform gem / libxml2 build error — Bundler: Your bundle only supports platforms ["x86_64-linux"] but your local platform is arm64-darwin / Could not find gem 'nokogiri (1.16.0-arm64-darwin)' (Ruby / Rails)Nokogiri: could not f…Bundler: …

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.