Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 580
Adam Spiers Avatar asked Nov 09 '10 11:11

Adam Spiers


People also ask

How do you check if I have a gem installed?

Since your goal is to verify a gem is installed with the correct version, use gem list . You can limit to the specific gem by using gem list data_mapper . To verify that it's installed and working, you'll have to try to require the gem and then use it in your code.

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

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.

like image 88
philosodad Avatar answered Nov 13 '22 13:11

philosodad


I know you said you weren't interested in answers about Bundler, but…

Bundler will handle gem dependency resolution for you and is compatible with Rails 2.3. I've used Bundler with a number of Rails 2 apps and not had any problems with it.

There are instructions for installing Bundler on Rails 2.3 here: http://gembundler.com/rails23.html

like image 29
georgebrock Avatar answered Nov 13 '22 12:11

georgebrock