/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
pwd # where you are
ls Gemfile Gemfile.lock
cd /path/to/project # replace with the folder that contains the Gemfile
bundle installRun Bundler for a Gemfile in another folder:
BUNDLE_GEMFILE=/path/to/project/Gemfile bundle exec rake testIn a Dockerfile, copy the Gemfile before installing:
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .| Situation | Fix |
|---|---|
| Terminal in the wrong folder | cd to the project root |
| Script run from cron or a service | Set the working directory or BUNDLE_GEMFILE |
| Docker build | COPY Gemfile Gemfile.lock before RUN bundle install |
| New project | bundle init, then bundle add GEM |
Sources
Related pages
commands · bundlerbundle exec: run a command with the Gemfile's gem versionsbundle exec CMD runs a command with exactly the gem versions in Gemfile.lock, avoiding conflicts with other installed versions. When you need it, and binstubs.errors · bundlerBundler: Could not find rake-13.2.1 in locally installed gemsCould not find GEM-VERSION in locally installed gems: Gemfile.lock lists a gem not installed for this Ruby. Run bundle install; check path and platforms.errors · bundlerYou have already activated rake 13.2.1, but your Gemfile requires rake 13.0.6Gem::LoadError You have already activated X, but your Gemfile requires Y: a newer gem loaded before Bundler. Run it with bundle exec, or align the versions.