How do I check that all the dependencies of my installed Ruby gems are satisfied?

Adam Spiers picture Adam Spiers · Nov 9, 2010 · Viewed 12.1k times · Source

I must be missing something because last night I was astonished to find that googling for check gem dependencies and similar didn't reveal the answer for this.

I'm basically after a rough equivalent of rpm -V - a command that will go through some or all my installed gems and make sure that their dependencies are also installed. Since gem install by default installs any dependent gems, normally this is not necessary; however, if you gem uninstall a gem and tell it to proceed with the uninstall even though other gems depend on the one being uninstalled, then obviously you will end up with broken dependencies. The question is, how do you then list those broken dependencies without installing / uninstalling / updating any gems?

N.B. answers which involve Bundler are not much use to me, since I'm still stuck on Rails 2.x for various reasons.

Answer

philosodad picture philosodad · Nov 12, 2010

in the bash shell:

gem list --no-version > list
gem dependency --pipe > depends
grep -v -f list depends > failed.txt
rm list
rm depends

failed.txt will now have a list of all dependencies that are not installed.