Skip to content

/errors/bundler/could-not-locate-gemfile

Bundler: Could not locate Gemfile

The commands on this page have not been executed by our verification runner yet.updated
tool
Bundler
exit code
10
versions
Bundler 2.x
os
linux, macos, windows

Could not locate Gemfile means Bundler searched the current directory and every parent directory for a Gemfile (or gems.rb) and found none. Bundler raises Bundler::GemfileNotFound, which exits with status 10. Run the command from the project root, point Bundler to the file with BUNDLE_GEMFILE, or create a Gemfile with bundle init for a new project.

Where it comes from

The message is raised in Bundler's SharedHelpers when it resolves the root of the bundle. Any command that needs a bundle reaches it first: bundle install, bundle exec, bundle update, bundle check and require "bundler/setup" in a script.

Fix

bash
pwd                    # where you are
ls Gemfile Gemfile.lock
cd /path/to/project    # replace with the folder that contains the Gemfile
bundle install

Run Bundler for a Gemfile in another folder:

bash
BUNDLE_GEMFILE=/path/to/project/Gemfile bundle exec rake test

In a Dockerfile, copy the Gemfile before installing:

Dockerfile
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .
SituationFix
Terminal in the wrong foldercd to the project root
Script run from cron or a serviceSet the working directory or BUNDLE_GEMFILE
Docker buildCOPY Gemfile Gemfile.lock before RUN bundle install
New projectbundle init, then bundle add GEM

Sources