My setup: Rails 3.0.9, Ruby 1.9.2
I want to check the gem version for my app through the Rails console. In my gemfile, I have
gem 'rack', '1.2.3'
Ran bundle install after. In the Rails console,
>> Rack.version
=> "1.1"
Any idea why?
UPDATE
Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionpack (3.0.9)
...
rack (~> 1.2.1)
...
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
warden (1.0.4)
rack (>= 1.0)
DEPENDENCIES
...
rack (= 1.2.3)
...
There are several rack versions listed in gemfile.lock
.
To view this information: Open the App bundle explorer page (Release > App bundle explorer). Select the version filter near the top right of the page. On the “Choose a version” table, select the right arrow on the version that you want to view.
To check if a specific version is installed, just add --version , e.g.: gem list -i compass --version 0.12.
The gem command allows you to interact with RubyGems. Ruby 1.9 and newer ships with RubyGems built-in but you may need to upgrade for bug fixes or new features. To upgrade RubyGems, visit the download page. If you want to see how to require files from a gem, skip ahead to What is a gem. Finding Gems.
Rack.version
will return the protocol version,
Rack.release
is probably what you are you looking for.
https://github.com/rack/rack/blob/master/lib/rack.rb#L14
Otherwise:
Gem.loaded_specs["rack"]
Example:
Gem.loaded_specs["rack"]
# => #<Gem::Specification name=rack version=1.3.2>
Gem.loaded_specs["rack"].version
# => #<Gem::Version "1.3.2">
Gem.loaded_specs["rack"].version.to_s
# => "1.3.2"
Every gem has ::VERSION constant.. so just use Rack::VERSION or OpenSSL::VERSION in console which should give you the version of gem loaded in that console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With