[OOT] rubygems: location of my gems

N

Nasir Khan

[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
 
M

michael greenly

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

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

Luis Lavena

[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,
 
J

James Tucker

gem which gemname

e.g.

raggi@mbk:~$ gem which hpricot
(checking gem hpricot-0.6 for hpricot)
/opt/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot.rb
 
J

James Gray

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 Gray II
 
N

Nasir Khan

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[OOT] Gem usage on Fedora 2
RubyGems woes 7
.irbrc location/path 0
[ANN] RubyGems 1.3.2 8
Need Help Creating Gems 2
Find Ruby /bin/ location 3
Rubygems update breaks other gems? 1
Using gems in a script or irb 2

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top