Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails console require nokogiri return false (but works in irb)

My environment is ruby 1.9.3p327 and rails 3.2.8 on a mac.

I add the gem nokogiri to my Gemfile. Run bundle install command. The command show me Using nokogiri (1.5.5) and the gem list command return nokogiri (1.5.5).

In the rails console require 'nokogiri' return false but in irb it return true.

How is this possible?

like image 319
wu ming Avatar asked Dec 19 '12 15:12

wu ming


1 Answers

According to the first two lines of the API documentation, require will:

  • return true if load successful
  • return false if already loaded
  • raise LoadError if file cannot be found

Since Rails console loads your gems, Nokogiri was probably required earlier. Irb doesn't do that.

like image 176
Matt Avatar answered Oct 13 '22 02:10

Matt