Last Updated: February 25, 2016
·
2.084K
· colindean

Generate a graph of Homebrew dependencies

Firstly, ensure that graphviz is installed with brew install graphviz.

You'll need to somehow get the graph command in one of two ways:

  1. Tap the boneyard with brew tap homebrew/boneyard. This will install an older version of the command, written in Python that parses brew deps. It may stop working as time goes on.
  2. Copy the brew-graph script from this project to somewhere on your PATH. It hasn't been updated in a while, so YMMV. You will have to write the data to a file with -o filename and modify the command below to read from that file until issue #2 is fixed.

Then you can do this with the Python version:

brew graph | dot -Tgif > deps.gif

Or this with the Ruby version:

brew graph -g all -o graph.dot
cat graph.dot | dot -Tgif > deps.gif
open deps.gif

This will generate something like this:

Picture

Use gif instead of png for this, as the image is only a few colors and otherwise ends up being huge.

2 Responses
Add your response

I think you may be missing the installation of something that provides the 'graph' command for brew?

/tmp$ brew graph
Error: Unknown command: graph
over 1 year ago ·

@grempe: It seems to have been removed. I can't seem to find when, but this project seems to provide at least the command. I've not tried it yet, though.

Edit: Found it. In commit 2496da48b34ee183b6873e090e91b0adf87cb674, brew-graph was moved to homebrew-boneyard. You can install the original with brew tap homebrew/boneyard, but it's probably better to use the aforementioned script, which tightly integrates with Homebrew, but hasn't been updated in years.

over 1 year ago ·