# Having a local copy of a gem - how to handle require\_gem?

**URL:** <https://www.ruby-forum.com/t/having-a-local-copy-of-a-gem-how-to-handle-require-gem/60956>\
**Category:** Ruby\
**Created:** [May 18, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/having-a-local-copy-of-a-gem-how-to-handle-require-gem/60956 "2006-05-18T22:09:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 18, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/having-a-local-copy-of-a-gem-how-to-handle-require-gem/60956/1 "2006-05-18T22:09:04Z")

</div>

In order to resolve namespace conflicts, I need to take ownership of two  
Rubygems.

This mean that I would like to take these gems, and put them in local,  
self-managed folders so that I can control their namespaces.

I am able to successfully require these modules, however, I can’t get  
the “require\_gem” call to work.

Should I be able to pass any arbitrary path that is not in my load path  
to a gem to require\_gem and expect it to work?

Example:

require\_gem “${RAILS\_ROOT}/app/modules/whatever.rb”

Does require\_gem only look on the load path? Would I need to add  
${RAILS\_ROOT}/app/modules to my Ruby load path?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 18, 2006, 10:17pm UTC](https://www.ruby-forum.com/t/having-a-local-copy-of-a-gem-how-to-handle-require-gem/60956/2 "2006-05-18T22:17:11Z")

</div>

On 5/18/06, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In order to resolve namespace conflicts, I need to take ownership of two  
> Rubygems.

Do not use require\_gem unless you wish to set a particular _version_.  
Even then, I would argue against because it still uses the  
“autorequire” functionality that will be removed eventually.

(IMO, a new verson of RubyGems should be released soon that has  
activate\_gem that does _not_ use autorequire and deprecates  
require\_gem.)

You have to specify the name of the gem to use require\_gem; require  
can be used to specify a full path.

-austin

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 18, 2006, 10:46pm UTC](https://www.ruby-forum.com/t/having-a-local-copy-of-a-gem-how-to-handle-require-gem/60956/3 "2006-05-18T22:46:18Z")

</div>

Wes G. wrote:

> In order to resolve namespace conflicts, I need to take ownership of two  
> Rubygems.
> 
> This mean that I would like to take these gems, and put them in local,  
> self-managed folders so that I can control their namespaces.
> 
> I am able to successfully require these modules, however, I can’t get  
> the “require\_gem” call to work.

I believe require\_gem is outdated.

Gem files are tarballs, containing two tgz archives. The data.tgz file  
has the code. Unpack this into a local directory, and push the path  
into the Ruby load path.

$:.unshift( ‘/path/to/unpacked/gem/lib’ )

For Rails, I believe that placing unpacked gems into the vendor dir  
allows this to be handled for you. (It’s referred to, I think as  
‘freezing’ a gem. It’s very handy.)

You’ll get better information on that on the Rails mailing list.

–  
James B.

[http://web2.0validator.com](http://web2.0validator.com) - We’re the Dot in Web 2.0  
[http://refreshingcities.org](http://refreshingcities.org) - Design, technology, usability  
[http://yourelevatorpitch.com](http://yourelevatorpitch.com) - Finding Business Focus  
[http://www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys
