Forum: Ruby Having a local copy of a gem - how to handle require_gem?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-05-18 22:09
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
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-05-18 22:17
(Received via mailing list)
On 5/18/06, Wes Gamble <weyus@att.net> 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
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-05-18 22:46
(Received via mailing list)
Wes Gamble 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 Britt

http://web2.0validator.com    - We're the Dot in Web 2.0
http://refreshingcities.org   - Design, technology, usability
http://yourelevatorpitch.com  - Finding Business Focus
http://www.jamesbritt.com     - Playing with Better Toys
This topic is locked and can not be replied to.