From: eva54321 on 2 Apr 2010 05:17 Hi, I saw people wrote "require 'rubygems'" in their scripts sometime. For what purpose is this module used? Thanks. -eva
From: Francesco Vollero on 2 Apr 2010 05:25 Il 02/04/10 11.17, eva54321 ha scritto: > Hi, > > I saw people wrote "require 'rubygems'" in their scripts sometime. > For what purpose is this module used? Thanks. > > -eva > > > > Using google, might help you, because is a FAQ but, i give you this website [1] that surely answer to your question. Cheers, Francesco [1] http://www.rubyinside.com/why-using-require-rubygems-is-wrong-1478.html
From: Josh Cheek on 2 Apr 2010 21:13 [Note: parts of this message were removed to make it a legal post.] On Fri, Apr 2, 2010 at 3:17 AM, eva54321 <eva54321(a)sina.com> 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.
|
Pages: 1 Prev: about define significance variable(in this situation) Next: Fill a table in ruby |