3
votes

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)

2
I'm not sure if you are aware that you don't have nokogiri in above list ;) Try running bundle exec irb so you will use gems from your Gemfile.zrl3dx
thanks for the suggestion. that worked out for me. if you create an answer then i will accept it.TaimoorQ

2 Answers

4
votes

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

0
votes

You should be running require 'rubygems' before loading any other gems. Rails does this for you, but IRB is not that fancy.

Otherwise, are you using a manager like RVM? Did you confirm that you're not switching in or out of a gemset?