# 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

**Code:** `Bundler: Could not find gem in locally installed gems` · **Category:** Ruby / Rails · **Seen on:** Ruby

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ruby/bundler-could-not-find-gem)
