Bundler "Could not locate Gemfile" in CI - Fix the Working Directory
By Daniel Zoghalchali·Latchkey
Bundler walked up from the current directory and never found a Gemfile. The step is running somewhere other than your project root, or the Gemfile is not present in the checkout.
What this error means
A bundle command fails immediately with "Could not locate Gemfile" before doing any work. It usually means the working directory is wrong, not that the Gemfile is missing from the repo.
bundler output
Could not locate Gemfile or .bundle/ directory
Diagnose it: Ruby version and platform
Bundler resolves against the Ruby version and the platform recorded in the lockfile. A runner on a different Ruby or a Linux platform missing from Gemfile.lock fails in a way that names a gem rather than the cause.
Terminal
ruby -v && bundle -v
cat .ruby-version 2>/dev/null
bundle platform
# the usual CI-only failure: Linux platform absent from the lockfile
bundle lock --add-platform x86_64-linux
bundle install --jobs 4 --retry 3
Common causes
Step runs in the wrong directory
The Gemfile lives in a subdirectory (a monorepo package or app/ folder) but the bundle command runs from the repo root, so Bundler never finds it.
Gemfile not checked out
A shallow or partial checkout, or a job that runs before the checkout step, leaves the runner without the Gemfile on disk.
How to fix it
Run bundle from the project directory
Set the working directory for the step, or point Bundler at the Gemfile explicitly.
Ensure the checkout step runs before any bundle command.
List the directory (ls -la) in the failing step to confirm the Gemfile is there.
For a monorepo, set working-directory or BUNDLE_GEMFILE per job.
How to prevent it
Set working-directory (or BUNDLE_GEMFILE) for bundle steps in subdirectories.
Always run the checkout step before bundle.
Keep one canonical Gemfile location per service and reference it consistently.
Frequently asked questions
What causes Bundler "Could not locate Gemfile" in CI?
There are 2 common causes: step runs in the wrong directory and gemfile not checked out. The Gemfile lives in a subdirectory (a monorepo package or app/ folder) but the bundle command runs from the repo root, so Bundler never finds it.
How do I fix Bundler "Could not locate Gemfile" in CI?
There are 2 fixes depending on which cause you have: run bundle from the project directory and confirm the gemfile is present. Work through them in order, since the first is the most common.
What does Bundler "Could not locate Gemfile" in CI actually mean?
A bundle command fails immediately with "Could not locate Gemfile" before doing any work.
How do I stop Bundler "Could not locate Gemfile" in CI happening again?
Set working-directory (or BUNDLE_GEMFILE) for bundle steps in subdirectories. The prevention section lists 3 changes that keep it from recurring.