How to see the dependency tree just from Gemfile?

RubyGemBundler

Ruby Problem Overview


I am getting the following error when doing bundle install

Make sure that `gem install couchbase -v '1.3.3'` succeeds before bundling.

Now, i have not included this gem in the Gemfile, so it's coming from some dependency. How can i figure out which gem is dependent on this couchbase gem?

Since bundle install is failing and I don't have Gemfile.lock to figure out this dependency.

Ruby Solutions


Solution 1 - Ruby

gem dependency (with no args) should show you all gems from current Gemfile with their dependencies.

Edit:

You can also do gem dependency -R (or just dep instead of dependency) if you want to find out which gems use specific (or all) gems.

For deeper dependencies I'd parse output (regex maybe?) of first gem dependencies, pick gem's names and call gem dep on each of them, but that's just a loose idea.

Solution 2 - Ruby

You can also use bundler to create a dependency graph.

Install graphviz:

gem install ruby-graphviz

and then:

bundle viz

Here are an example of a newly created Rails app:

Rails app dependency graph

You can also play with the options:

bundle help viz 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMohit VermaView Question on Stackoverflow
Solution 1 - Rubyzrl3dxView Answer on Stackoverflow
Solution 2 - RubyPaulo FidalgoView Answer on Stackoverflow