wu ming
wu ming

Reputation: 161

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?

Upvotes: 14

Views: 5423

Answers (1)

Matt
Matt

Reputation: 5398

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.

Upvotes: 38

Related Questions