From: Josh Cheek Date: 2010-04-03T10:13:30+09:00 Subject: Re: require rubygems --000e0cd29280b41ad504834acd2c Content-Type: text/plain; charset=ISO-8859-1 On Fri, Apr 2, 2010 at 3:17 AM, eva54321 wrote: > Hi, > > I saw people wrote "require 'rubygems'" in their scripts sometime. > For what purpose is this module used? Thanks. > > -eva > > > In Ruby, libraries (sets of code you can use in your program that other people wrote) are called gems. Most people use Rubygems to manage their gems, such as installing, uninstalling, installing specific versions, etc (see rubygems.org) For some annoying reason that has to do with the load path, Ruby can't find the gems you have installed unless you first require rubygems. So people who want to use those gems will require rubygems in their file before requiring the gem itself, so that the gem loads correctly. The alternative is to set some environment variable. $ RUBYOPT="rubygems" $ export RUBYOPT $ ruby FOO.rb But really, you'd want to put that in your .profile so you don't have to explicitly do it every time you open a terminal window. In ruby 1.9, rubygems are apparently loaded by default, or the path is modified, or something such that you don't have to worry about it anymore. --000e0cd29280b41ad504834acd2c--