Difference between gem and require (require open-uri)

WHITECOLOR picture WHITECOLOR · Dec 3, 2011 · Viewed 25.9k times · Source

I just wanted to understand for my self.

I'm using the nokogiri gem (for parsing HTML). If I got it right to open URLs I need to use a method from the gem 'open-uri'.

But when I include it in my Gemfile (on Windows developer's machine):

gem 'open-uri' - there is an error while bundle install that it can not find gem.

So If I use require 'open-uri' - its working.

So can some explain what is going on?

Answer

lucapette picture lucapette · Dec 3, 2011

You're using bundler for your gem dependecies and you're doing it right but OpenUri is part of the Ruby standard library. That's why you only need to require it if you want to use it in your code.