/errors/bundler/could-not-find-gem-in-locally-installed-gems
Bundler: Could not find rake-13.2.1 in locally installed gems
- tool
- Bundler
- exit code
- 7
- versions
- Bundler 2.x
- os
- linux, macos, windows
Could not find rake-13.2.1 in locally installed gems (raised as Bundler::GemNotFound) means Gemfile.lock asks for a gem version that is not installed in the place Bundler is looking, for the Ruby that is running. It appears when you run bundle exec, rails or rake after the lock file changed but before bundle install. Run bundle install; if the error persists, compare the Ruby version, Bundler's path setting and the platforms in Gemfile.lock.
Fix
bundle install # installs what Gemfile.lock lists
bundle exec rake -T # run tools through bundle execBundler prints Run bundle install to install missing gems. after the error, and in most cases that is all that is needed.
When bundle install does not help
| Check | Command | What to look for |
|---|---|---|
| Ruby version | ruby -v and the RUBY VERSION section of Gemfile.lock | A Ruby switch means a fresh, empty gem directory |
| Install location | bundle config get path | Install and run must use the same BUNDLE_PATH (vendor/bundle or system) |
| Excluded groups | bundle config get without | The gem may be in a group that was skipped |
| Platforms | grep -A5 PLATFORMS Gemfile.lock | Your platform (x86_64-linux, arm64-darwin...) must be listed for native gems |
| Frozen mode | bundle config get frozen | In frozen or deployment mode, Bundler will not re-resolve a lock that lacks your platform |
Missing platform (Docker and CI)
A lock file created on macOS (arm64-darwin) may lack the Linux platform used in Docker or CI, so native gems such as nokogiri have no matching variant there. Add the platform and commit the lock file:
bundle lock --add-platform x86_64-linux aarch64-linux
git add Gemfile.lock