I\'m investigating a rails app - the prod server has two version of a specific gem installed, how can I tell which version the prod app is using?
In newer version, used bundle show gem_name
[DEPRECATED] use `bundle info gem_name` instead of `bundle show gem_name`
If you use bundler, then you can get the version using:
bundle info [gemname]
In the terminal
bundle show <gem-name>
bundle show | grep <gem-name>
or
gem list | grep <gem-name>
For example:
bundle show rails
bundle show | grep rails
gem list | grep rails
script/about
will tell you what versions of the core Rails and Rack gems you're using, but not anything else. Ideally, if you look in config/environment.rb
, there should be a section that looks like this:
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
With any luck, the author of the app will have included any required gems and versions there. However, the versions are optional in this file, and ultimately nothing stops an inexperienced developer from just slapping a require 'rubygems'; require 'some_random_thing'
at the top of any given file.
If you see that a gem is being required, but no version is specified, you can type gem list
to see all the versions of all the gems on the system. By default, it will be using the latest one available.
In Rails 3 and Rails 4, use bundle show
In Rails 2, rake gems
will print out what gems, dependencies, and versions are installed, frozen, etc.
gem list <gemname>
It will show all the matching gems e.g if some one do
gem list rack
Then th output will be as following
*** LOCAL GEMS ***
rack (1.6.4)
rack-mount (0.6.14)
rack-test (0.6.3, 0.6.2, 0.5.7)