IRB showing "LoadError: cannot load such file -- nokogiri" error when trying to require "nokogiri"

irb, nokogiri, ruby, ruby-on-rails

Solution

All you need to do is to run `bundle exec irb` to use gems from Gemfile.

Problem

In IRB when I type require "nokogiri", I get the following error: ``` LoadError: cannot load such file -- nokogiri ``` I have the nokogiri gem installed in my gemfile and can use it in Rails with no problem, but in IRB it throws an error. I'm on OSX Mavericks in case that helps. Below is a list of my local gems: actionmailer (4.0.2) actionpack (4.0.2) activemodel (4.0.2) activerecord (4.0.2) activerecord-deprecated_finders (1.0.3) activesupport (4.0.2) arel (4.0.1) atomic (1.1.14) builder (3.1.4) bundler (1.3.5) erubis (2.7.0) hike (1.2.3) i18n (0.6.9) mail (2.5.4) mime-types (1.25.1) minitest (4.7.5) multi_json (1.8.2) polyglot (0.3.3) rack (1.5.2) rack-test (0.6.2) rails (4.0.2) railties (4.0.2) rake (10.1.0) sprockets (2.10.1) sprockets-rails (2.0.1) thor (0.18.1) thread_safe (0.1.3) tilt (1.4.1) treetop (1.4.15) tzinfo (0.3.38)

Original source