# Require rubygems

**URL:** <https://www.ruby-forum.com/t/require-rubygems/186216>\
**Category:** Ruby\
**Created:** [April 2, 2010, 11:18am UTC](https://www.ruby-forum.com/t/require-rubygems/186216 "2010-04-02T11:18:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eva54321](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@eva54321](https://www.ruby-forum.com/u/eva54321)\
**Post date:** [April 2, 2010, 11:18am UTC](https://www.ruby-forum.com/t/require-rubygems/186216/1 "2010-04-02T11:18:06Z")

</div>

Hi,

I saw people wrote “require ‘rubygems’” in their scripts sometime.  
For what purpose is this module used? Thanks.

-eva

---

<div class="post-metadata">

**Author:** ![eva54321](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@eva54321](https://www.ruby-forum.com/u/eva54321)\
**Post date:** [April 2, 2010, 11:26am UTC](https://www.ruby-forum.com/t/require-rubygems/186216/2 "2010-04-02T11:26:18Z")

</div>

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](http://www.rubyinside.com/why-using-require-rubygems-is-wrong-1478.html)

---

<div class="post-metadata">

**Author:** ![eva54321](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@eva54321](https://www.ruby-forum.com/u/eva54321)\
**Post date:** [April 3, 2010, 3:14am UTC](https://www.ruby-forum.com/t/require-rubygems/186216/3 "2010-04-03T03:14:00Z")

</div>

On Fri, Apr 2, 2010 at 3:17 AM, eva54321 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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.
