0

Let's say I have a file in my GEM_HOME's bin directory, like ~/.gem/ruby/2.4.0/bin/foo or something along those lines. How can I determine which gem owns that file?


Here are similar questions for other package managers; I'm looking for an answer specifically for Ruby gems:

1 Answer 1

1

Open the bin file and look at its contents. It should be just a plain Ruby file. Somewhere towards the end you will usually see something like this:

load Gem.bin_path('gemname', 'gemname', version)

Where gemname will be the name of the gem the file belongs to.

If a line like that is not present, you will have to do a bit of detective work, but usually you can figure it out from either the bin name, or the code that is in the file itself.

You can also quickly verify bin contents of a specific gem like this, which may help in tracking down candidates:

gem contents gemname | grep bin

Or if you just want to scan everything:

gem contents --all | grep file_you_want_to_find
2
  • Thanks, but I'm looking for a general answer, not an answer that's specific to files in the bin directory (that's just something I gave as an example).
    – jayhendren
    May 11, 2018 at 22:35
  • See my last edit. You can use gem contents --all and just grep it for anything you need.
    – Casper
    May 11, 2018 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.