Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trace and check dependencies in bundled Ruby gems

Bundler will automatically install any dependencies for the specified gems, however it doesn't output which dependencies map to which gems in the standard output. That information is useful when one of the dependencies fails the installation.

Is there a way to set Bundler to be more verbose and inform about the dependencies while installing?

I am using Bundler 1.0.2

like image 782
Samer Buna Avatar asked Oct 06 '10 01:10

Samer Buna


People also ask

How do I see gem dependencies?

You can always check the reverse dependencies of a gem on rubygems.org. There's a link on the right side panel on the website.

What is dependencies in Ruby?

Dependencies can be downloaded when your function is deployed, or packaged locally alongside your function. Each function must provide a Gemfile that specifies the functions_framework gem, along with any additional gems needed by the function. Gemfile must be in the same directory as the app.


2 Answers

To see a visual representation of the dependency tree run bundle viz:

apt-get install graphviz && gem install ruby-graphviz && bundle viz

It will generate a PNG file of the tree.

like image 74
Samer Buna Avatar answered Nov 15 '22 15:11

Samer Buna


A less exciting, but equally effective way is to just do:

gem dep

which will generate a Gemfile.lock style output with dependency information. You could pipe this output to less:

gem dep | less

Or, if you are searching for a failing dependency, you could grep it with some context. For instance, to find out where my failing Thin dependency was coming from (fails with JRuby), I did:

gem dep | grep -C 15 thin
like image 39
ipd Avatar answered Nov 15 '22 14:11

ipd