Gem.bin_path('cucumber', 'cucumber')
Will return the binary/executable's path. It seems there is no such function to return the library path. Which in this case would, ideally, return:
/home/hedge/.rvm/gems/ruby-1.9.2-p136@bbb-bdd-meta-bdd/gems/cucumber-0.10.0/lib
Have I missed something or is there a simple/one method way to get this information?
Updated: No CLI or non-stdlib suggestions please.
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.
RubyGems is a system for managing Ruby software libraries. Ruby code packaged in this manner is called a gem. When you find Ruby software you want to use in a project, gems offer a means of downloading, installing and managing the software. History.
The problem with the checked answer is that you must "require" the rubygem or it won't work. Often this is undesireable because if you're working with an executable gem, you don't want to "require" it or you'll get a bunch of warnings.
This is a universal solution for executables and libs:
spec = Gem::Specification.find_by_name("cucumber") gem_root = spec.gem_dir gem_lib = gem_root + "/lib"
If you want to get really technical, there isn't just one lib directory. The gemspec has a "require_paths" array of all the directorys to search (added to $LOAD_PATH). So, if you want an array of the require_paths, use this:
gem_lib = gem_root + "/" + spec.require_paths[0]
No need for bundler.
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