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?
Try using script/about
. Your config/environment.rb
also has information about it.
In your config/environment.rb
you can specify which version of a particular gem
the application should use. However if you have multiple versions of a gem
installed on your machine and you do not specify the version, the latest version of that gem will be used by the application.
There probably is a more direct way to find this out, but if you load up a console and require a specific version like so:
gem 'RedCloth', '3.0.4'
It will tell you what version is already activated:
=> Gem::LoadError: can't activate RedCloth (= 3.0.4, runtime) for [], already activated RedCloth-4.2.2
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.
rake gems
will print out what gems, dependencies, and versions are installed, frozen, etc.