[ruby] How to upgrade rubygems

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:~$

This question is related to ruby gem

The answer is


I wouldn't use the debian packages, have a look at RVM or Rbenv.


You can update gem to any specific version like this,

gem update --system 'version'

gem update --system '2.3.0'

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

For me it sufficed to simply run

gem update

Or:

gem update `gem outdated | cut -d ' ' -f 1`

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.


You can update all gems by just performing:

sudo gem update