How to list Ruby gems in the bundle

Bundler, a Ruby package manager, provides two options to list gems in the bundle.

If no options provided, both commands print a list of gems and their versions. As well as they output the list of paths of all gems, when executed with the --paths option.

The difference between two commands becomes visible when other options are provided.

  • bundle list can print the list with additional group fileters applied.
  • bundle show is suitable to get the path of only one gem in the bundle.

Interesting story

Wondering why two different commands would print very similar output, I decided to look into their source code. That lead to a an interesting discovery.

There was some sort of “competition” between bundle list and bundle show. One command was supposed to be depricated in favour of another. Then due to a mistake that another command was marked for deprication. After an attempt to “fix” the deprecation confusion, it was decided to keep both commands.

A short competition story.

Lesson: if two commands produce similar output, it would be confusing not just when you use these commands, but also when you maintain them as an author.

Credits

Thank you Pablo Vicente for showing me bundle show.


TIL rating:
good to know

Read next