Ruby: LoadError: cannot load such file -- nokogiri (or: cannot load such file -- bundler/setup)
require couldn't find the file/gem — it isn't installed, not in the Gemfile, or the load path is wrong.
LoadError: cannot load such file -- nokogiricannot load such file -- bundler/setupLoadError (cannot load such file -- ./config/boot)cannot load such file -- rails/commandsLoadError: cannot load such file -- sqlite3/sqlite3_native Meaning
Run bundle install, add the gem to the Gemfile, use bundle exec, and check ruby -v matches the environment where gems were installed (rbenv/rvm). For local files use require_relative. Missing system libraries cause different (ext build) errors.
Common causes
- Gem not installed/in Gemfile
- Not using
bundle exec - Different Ruby version than the gems were installed for
- Wrong relative path
- Case mismatch on Linux
⚡ Quick fix
bundle installthenbundle exec ...- Check
which ruby && ruby -vand rbenv/rvm - Use
require_relative "path"for project files
Detailed fix by platform
Ruby
bundle exec ruby -e 'require "nokogiri"; puts Nokogiri::VERSION'
How to diagnose
- Gem — In Gemfile?
- Ruby — Same version?
- Command — bundle exec?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- ActiveRecord::ConnectionNotEstablished Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found
- ArgumentError: missing keyword / unknown keyword Ruby: ArgumentError: missing keyword: :name / unknown keyword: :nmae
- ArgumentError: wrong number of arguments (given 1, expected 2) Ruby: ArgumentError: wrong number of arguments (given 1, expected 2..3)
Most viewed in Ruby / Rails
- ActiveRecord::PendingMigrationError Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
- undefined method for nil Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass)
- ActionController::InvalidAuthenticityToken Rails: ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026