I know you can do
bundle show gem_name
to show the path of some gem.
How do you do that from within the code using the Bundler object?
Since your goal is to verify a gem is installed with the correct version, use gem list . You can limit to the specific gem by using gem list data_mapper . To verify that it's installed and working, you'll have to try to require the gem and then use it in your code.
I know that when using gem install , the gem will be stored under /home/username/. rvm/gems/, under which gemset the gem was installed.
Think of bundler as a package management tool. So bundle install command will install all gems to the system that are listed in Gemfile as well as their dependencies. If the gem was not previously installed it will grab it from the gemcutter repo.
Have a look at how they do it in cli.rb
def locate_gem(name)
spec = Bundler.load.specs.find{|s| s.name == name }
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
if spec.name == 'bundler'
return File.expand_path('../../../', __FILE__)
end
spec.full_gem_path
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With