The problem with the verified answer is that you have to “require” rubygem, otherwise it will not work. This is often undesirable because if you are working with an executable stone, you do not want to “require” it, or you will receive 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 is more than one lib directory. Gemspec has an array of "require_paths" for all directories to search (added to $ LOAD_PATH). So, if you need an array of require_paths, use this:
gem_lib = gem_root + "/" + spec.require_paths[0]
No need to bind.
user1182000 Apr 10 2018-12-12T00: 00Z
source share