Rubygems: location of my gems

Hi,

Is there an easy way of finding the location of my installed gem
programmatically.
I need this to create an environment variable.

Thanks
Nasir

not in front of a computer but ‘gem env | grep -i gempath’ should come
close
to working

On 4 ene, 16:49, Nasir K. [email protected] wrote:

[Note: parts of this message were removed to make it a legal post.]

Hi,

Is there an easy way of finding the location of my installed gem
programmatically.
I need this to create an environment variable.

C:\Documents and Settings\Usuario>irb
irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> Gem.dir
=> “C:/Ruby/lib/ruby/gems/1.8”
irb(main):003:0>

HTH,

gem which gemname

e.g.

[email protected]:~$ gem which hpricot
(checking gem hpricot-0.6 for hpricot)
/opt/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot.rb

On Fri, 04 Jan 2008 13:49:21 -0500, Nasir K. wrote:

[Note: parts of this message were removed to make it a legal post.]

Hi,

Is there an easy way of finding the location of my installed gem
programmatically.
I need this to create an environment variable.

Thanks
Nasir

FILE will tell you the location of the file in which you use it. So
when my SqlStatement gem is installed on Debian, the location of
sqlstatement.rb is /var/lib/gems/1.8/gems/SqlStatement-1.0.2/lib/
sqlstatement.rb, and I can find other paths in the directory tree by
taking them relative to the known location of that file in my directory
tree.

–Ken

On Jan 4, 2008, at 12:49 PM, Nasir K. wrote:

Is there an easy way of finding the location of my installed gem
programmatically.

Sure:

gem_spec = Gem::GemPathSearcher.new.find(require_name)
gem_dir = File.join(gem_spec.full_gem_path, gem_spec.require_path)

Hope that helps.

James Edward G. II

This is exactly what I was looking for. Thanks a lot.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs