Using the command-line gem
tool, how can I install a specific version of a gem?
There are several ways to specify gem versions: Use a specific version: gem "name-of-gem", "1.0" . You can find specific versions on Rubygems.org (provided that's the source you”re using) by searching for your gem and looking at the “Versions” listed. Use a version operator: gem "name-of-gem", ">1.0" .
Selecting a version of Ruby You'll need to install bundler 1.2. x or above to use the ruby keyword and bundler 1.13. x or above to use a Ruby version specifier. You can use the ruby keyword in your app's Gemfile to specify a specific version of Ruby.
Use the --version
parameter (shortcut -v
):
$ gem install rails -v 0.14.1 … Successfully installed rails-0.14.1
You can also use version comparators like >=
or ~>
$ gem install rails -v '~> 0.14.0' … Successfully installed rails-0.14.4
With newer versions of rubygems you can tighten up your requirements:
$ gem install rails -v '~> 0.14.0, < 0.14.4' … Successfully installed rails-0.14.3
Since some time now you can also specify versions of multiple gems:
$ gem install rails:0.14.4 rubyzip:'< 1' … Successfully installed rails-0.14.4 Successfully installed rubyzip-0.9.9
But this doesn't work for more than one comparator per gem (yet).
Use the -v
flag:
$ gem install fog -v 1.8
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