ironsand ironsand - 1 year ago 55
Ruby Question

Which version of gem is used when there is no Gemfile

There is similar question here.
Ruby: Rails: Which version of a gem is used?

But it's about when

is used.

I want to know if there is no Gemfile, which version of gem is used.

For example I have 4 versions of
in my system.

% gem list | grep selenium
selenium-webdriver (2.53.0, 2.48.1, 2.46.2, 2.45.0)

And I just use it by
require 'selenium-webdriver
. How can I know which version is used? Only the latest is selected?

Answer Source

You probably have more than one gem because each project with Gemfile in your machine have one different version of it.

When using the gem via require or command line without specifying the version the last one - the greater version - will be automatically used.

By convention, in the most part of the cases, you can print the version doing the following:

require 'some_gem'
puts SomeGem::VERSION
# => "3.0.3"