How to upgrade rubygems
RubyGemRuby Problem Overview
I need to upgrade gems to 1.8 i tried installing the respective debian packages but it seems its not getting upgraded
anujm@test:~$ dpkg -l |grep -i rubygem
ii rubygems 1.3.5-1ubuntu2 package management framework for Ruby libraries/applications
ii rubygems-lwes 0.8.2-1323277262 LWES rubygems
ii rubygems1.8 1.3.5-1ubuntu2 package management framework for Ruby libraries/applications
ii rubygems1.9 1.3.5-1ubuntu2 package management framework for Ruby libraries/applications
anujm@test:~$
anujm@test:~$ gem
gem gem1.8 gem1.9
anujm@test:~$ sudo gem1.8 install serve
ERROR: Error installing serve:
multi_json requires RubyGems version >= 1.3.6
anujm@test:~$
Ruby Solutions
Solution 1 - Ruby
Install rubygems-update
gem install rubygems-update
update_rubygems
gem update --system
run this commands as root or use sudo.
Solution 2 - Ruby
You can update all gems by just performing:
sudo gem update
Solution 3 - Ruby
Or:
gem update `gem outdated | cut -d ' ' -f 1`
Solution 4 - Ruby
I found other answers to be inaccurate/outdated. Best is to refer to the actual documentation.
Short version: in most cases gem update --system
will suffice.
You should not blindly use sudo
. In fact if you're not required to do so you most likely should not use it.
Solution 5 - Ruby
You can update gem to any specific version like this,
gem update --system 'version'
gem update --system '2.3.0'
Solution 6 - Ruby
Solution 7 - Ruby
For me it sufficed to simply run
gem update
Solution 8 - Ruby
To update just one gem (and it's dependencies), do:
bundle update gem-name
But to update just the gem alone (without updating it's dependencies), do
bundle update --source gem-name
Solution 9 - Ruby
If you're using RVM, the command below helped me a lot when upgrading from a very very old rubygems (eg 1.3.7) that defies the more current update commands mentioned in the other responses in this thread.
rvm rubygems <version>