# RubyGems New gem() Method

**URL:** <https://www.ruby-forum.com/t/rubygems-new-gem-method/87071>\
**Category:** Ruby\
**Created:** [February 27, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/rubygems-new-gem-method/87071 "2007-02-27T23:52:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 27, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/rubygems-new-gem-method/87071/1 "2007-02-27T23:52:49Z")

</div>

Am I understanding right that the new gem() does not actually perform  
the require? It just sets up version handling, right?

Does this work for something like the soap4r gem? You can’t require  
that gem normally, because the standard library will take  
precedence. In the past, require\_gem() got around this but I’m  
thinking we lost that trick.

Am I missing something?

James Edward G. II

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 28, 2007, 12:15am UTC](https://www.ruby-forum.com/t/rubygems-new-gem-method/87071/2 "2007-02-28T00:15:52Z")

</div>

On Feb 27, 2007, at 14:52, James Edward G. II wrote:

> Am I understanding right that the new gem() does not actually  
> perform the require? It just sets up version handling, right?

Kernel#gem adds the gem’s require\_paths to $:.

> Does this work for something like the soap4r gem? You can’t  
> require that gem normally, because the standard library will take  
> precedence. In the past, require\_gem() got around this but I’m  
> thinking we lost that trick.

No, #gem doesn’t do autorequire. That’s the only difference.

> Am I missing something?

Yes. Use #gem.

---

<div class="post-metadata">

**Author:** ![bbazzarrakk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/47e85d/32.png) [@bbazzarrakk](https://www.ruby-forum.com/u/bbazzarrakk)\
**Post date:** [February 28, 2007, 12:21am UTC](https://www.ruby-forum.com/t/rubygems-new-gem-method/87071/3 "2007-02-28T00:21:52Z")

</div>

On Feb 27, 2007, at 5:15 PM, Eric H. wrote:

> On Feb 27, 2007, at 14:52, James Edward G. II wrote:
> 
> > Am I understanding right that the new gem() does not actually  
> > perform the require? It just sets up version handling, right?
> 
> Kernel#gem adds the gem’s require\_paths to $:.

So gem prepends them to $:, so they will be found before the standard  
libraries? Good to know.

James Edward G. II
