Reputation: 1861
I know that if application uses bundler, I can easily find all the gems installed by looking at the Gemfile.
Say, I am looking at the Rails 3 application that doesn't use bundler, how do I know what gems it uses?
Thanks
Upvotes: 0
Views: 65
Reputation: 17323
If it's not using Bundler, I don't know of a definitive way to identify every gem being used. You could search the entire app tree for require
statements to start with, but that's not going to show most of them. Gems also require other gems internally, and will install their own dependencies, but those gems won't be referenced directly from your app's require
statements.
If the app works and the tests pass (meaning you've at least got all the required gems installed), you could approach the problem by creating a Gemfile
, listing the gems you know are needed, and then running your tests (or the app itself) via bundle exec
, which will ensure that only the gems listed in the Gemfile
are visible. Then you'll get failures related to missing gems, and can add them to the Gemfile
until it all works. Once it's working via bundle exec
, you'll know that you've captured all the requirements there.
If you're using RVM, you'll probably find it helpful to create a gemset for your app, along with a .rvmrc
file in the app root, to take advantage of RVM's automatic gemset switching and Bundler integration. It'll make it easier to maintain the gem state going forward.
In any case, running gem list
with the app in a working state will show you all the gems that it might be using, but without being scoped to a gemset or wrapped in bundle exec
, you'll also see gems that were installed for other reasons that potentially have nothing to do with your app's dependencies.
Upvotes: 2