Bundler::GemRequireError in CI
Bundler.require auto-loads every gem in the relevant groups. One of them raised while being required, and Bundler wraps that in a GemRequireError naming the offending gem.
What this error means
Boot fails with Bundler::GemRequireError naming a gem, with the underlying error nested below. It often appears after a gem upgrade, a missing native dependency, or an incompatible Ruby version.
Bundler::GemRequireError: There was an error while trying to load
the gem 'nokogiri'.
Gem Load Error is: cannot load such file -- nokogiri/nokogiriCommon causes
Native extension not built for the runner
A gem with a C extension was installed for a different platform/Ruby, so its compiled object is missing when required on the runner.
Gem incompatible with the Ruby version
The installed gem version does not support the Ruby CI runs, and it errors at require time.
App code in the gem load path raises
An initializer or required file triggered during Bundler.require raises (e.g. a missing constant or bad config).
How to fix it
Read the nested error and address it
- Look at the "Gem Load Error is:" line under the wrapper for the real cause.
- Reinstall native gems for the runner platform: bundle config set force_ruby_platform, or bundle install with build tools present.
- Align the gem version with the Ruby version CI uses.
Force a clean platform-correct install
bundle config set --local force_ruby_platform false
rm -rf vendor/bundle
bundle installHow to prevent it
- Match gem versions to the Ruby version CI runs.
- Cache the bundle keyed on platform and Ruby version, not just the lockfile.
- Install required system build tools before bundle install for native gems.