# RubyGems 0.9.1 calling a gem with gem '\<gem\>'

**URL:** <https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530>\
**Category:** Ruby\
**Created:** [January 26, 2007, 11:47pm UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530 "2007-01-26T23:47:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![austin7873](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@austin7873](https://www.ruby-forum.com/u/austin7873)\
**Post date:** [January 26, 2007, 11:47pm UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530/1 "2007-01-26T23:47:59Z")

</div>

After upgrading to RubyGems 0.9.1, I’m seeing the following error:

irb(main):001:0\> require ‘rubygems’  
=\> true  
irb(main):002:0\> gem ‘uuid’  
=\> true  
irb(main):003:0\> UUID.new  
NameError: uninitialized constant UUID  
from (irb):3  
irb(main):004:0\>

This problem doesn’t happen if I use:

require ‘uuid’

or

require\_gem ‘uuid’

I’m also seeing similar problems calling other gems such as:  
gem ‘reliable msg’

I’ve run gem pristine -all  
I’ve tried reinstalling 0.9.1  
I’ve deleted both root and my user source\_cache

without any luck.

thanks in advance!

---

<div class="post-metadata">

**Author:** ![austin7873](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@austin7873](https://www.ruby-forum.com/u/austin7873)\
**Post date:** [January 27, 2007, 12:10am UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530/2 "2007-01-27T00:10:28Z")

</div>

> This problem doesn’t happen if I use:  
> require ‘uuid’

Well, you should use require, not gem. I.e.:  
require ‘rubygems’  
require ‘my\_gem’

See [http://rubygems.org/read/chapter/3#page70](http://rubygems.org/read/chapter/3#page70) (section 3.4).  
‘gem’ does something different than you think.

Regards,  
Rimantas

---

<div class="post-metadata">

**Author:** ![austin7873](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@austin7873](https://www.ruby-forum.com/u/austin7873)\
**Post date:** [January 27, 2007, 12:27am UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530/3 "2007-01-27T00:27:45Z")

</div>

Rimantas L. wrote:

> ‘gem’ does something different than you think.

I was using: gem ‘uuid’

because I had been using: require\_gem ‘uuid’  
but ran in to the deprecated warning that many people have already  
discussed:

Warning: require\_gem is obsolete. Use gem instead.

Maybe I’m misinterpreting the “Use gem instead” part?

---

<div class="post-metadata">

**Author:** ![austin7873](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@austin7873](https://www.ruby-forum.com/u/austin7873)\
**Post date:** [January 27, 2007, 12:43am UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530/4 "2007-01-27T00:43:30Z")

</div>

> I was using: gem ‘uuid’
> 
> because I had been using: require\_gem ‘uuid’  
> but ran in to the deprecated warning that many people have already  
> discussed:
> 
> Warning: require\_gem is obsolete. Use gem instead.
> 
> Maybe I’m misinterpreting the “Use gem instead” part?

It depends 🙂 ‘gem’ tells your program that you are going to use some  
gem, but it does not  
require it, so you still have to use ‘require’.  
Let’s say you have two versions of ‘my\_gem’, 0.1 and 0.2. rubygems  
will use the latest by default, but in case you need the first version  
you can do the following:

require ‘rubygems’  
gem ‘my\_gem’, ‘=0.1’  
require ‘my\_gem’

I think you’ve got bitten by the autorequire feature wich no longer  
works. require\_gem used to specify the gem and require it, ‘gem’ only  
add the gem to load path, you still have to require it.

---

<div class="post-metadata">

**Author:** ![austin7873](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@austin7873](https://www.ruby-forum.com/u/austin7873)\
**Post date:** [January 27, 2007, 1:10am UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530/5 "2007-01-27T01:10:33Z")

</div>

> I think you’ve got bitten by the autorequire feature wich no longer  
> works. require\_gem used to specify the gem and require it, ‘gem’ only  
> add the gem to load path, you still have to require it.

Thanks Rimantas, you’ve been super helpfull. looks like autorequire in  
require\_gem was throwing me for a loop. 🙂

---

<div class="post-metadata">

**Author:** ![austin7873](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@austin7873](https://www.ruby-forum.com/u/austin7873)\
**Post date:** [January 27, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/rubygems-0-9-1-calling-a-gem-with-gem-gem/83530/6 "2007-01-27T23:06:39Z")

</div>

On Jan 26, 2007, at 14:48, Austin 7873 wrote:

> After upgrading to RubyGems 0.9.1, I’m seeing the following error:
> 
> irb(main):001:0\> require ‘rubygems’  
> =\> true  
> irb(main):002:0\> gem ‘uuid’  
> =\> true  
> irb(main):003:0\> UUID.new  
> NameError: uninitialized constant UUID  
> from (irb):3  
> irb(main):004:0\>

This is expected, you haven’t required ‘uuid’ yet.

> This problem doesn’t happen if I use:
> 
> require ‘uuid’

#gem only adds a gem’s paths to the load path. You still need to  
require the library you’re interested in.

> or
> 
> require\_gem ‘uuid’

#require\_gem triggers the deprecated auto-require feature (deprecated  
along with #require\_gem in 0.9.0). RubyGems custom require is smart,  
so auto-require is no longer necessary.

You really only need to use #gem when you need a specific version of  
a gem loaded.

Usually:

require ‘rubygems’  
require ‘uuid’

is all you need.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)

I LIT YOUR GEM ON FIRE!
