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?
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?
Update: starting with Bundler v1.3.0, there is a public interface for obtaining a Gem's path:
Pre-v1.3.0, you may want to use the original solution shared (a private interface):
Yup, cli.rb is the best way to look at. However you anyway have to find a spec's name.
I can give you a starting point, but you have to come with some solution on how to optimize to your case:
Unfortunately this solution provides nameless search as all Gems are in an array instead of hash, but if you want you can hack GemPathSearcher, I think that would be useful in the future.
It turns out you actually want to use
Gem
for this, notBundler
.path = Gem.loaded_specs[NAME_OF_GEM].full_gem_path
Have a look at how they do it in cli.rb