• Home
  • Linux
  • How to install Ruby and Gems on CentOS 5.5



  • Decrease
  • Increase

How to install Ruby and Gems on CentOS 5.5

 

UPDATE: This article may help you, however if you are looking for more flexible way to install and handle multiple versions of Ruby on one system, you should check my article about Installing RVM (Ruby Version Manager) and Ruby 1.8.7/1.9.2/REE on CentOS 5.6 64Bit.

If you think that having yum handy and Ruby in one of the online repositories will make your life easy, think again.

There is always something that is missing. So here are the pieces of the puzzle.

Note: The following shows that pretty much everything in it was done as root and on a default CentOS installation (which is NOT a good practice for production environments due to security issues). However, it was quick and easy way to show everything – and you can improvise for your own environment.

Before we forget of course, we install the Atomic repository for CentOS (if we haven’t already):


[root@centos5 ~]# wget -q -O - http://www.atomicorp.com/installers/atomic |sh


The current version available in CentOS 5.5 repo is 1.8.5 release 5.el5_4.8. To make it easier, we are going to install what is available.

We begin by installing Ruby:


[root@centos5 ~]# yum install ruby


After the ruby and its dependencies install, we have to go get the latest Gems version which supports Ruby 1.8.5.

Since the latest Gems version is 1.3.7, it took me only two tries to figure out that the latest supported by Ruby 1.8.5 is Gems 1.3.5 or below. Here is what I got when I tried 1.3.7:


[root@centos5 rubygems-1.3.7]# ruby setup.rb
ERROR: Expected Ruby version >= 1.8.6, is 1.8.5


After finding out that Gems 1.3.5 is my version, I attempted to install and I got the following:

[root@centos5 ~]# cd rubygems-1.3.5
[root@centos5 rubygems-1.3.5]# ruby setup.rb
RubyGems 1.3.5 installed
./lib/rubygems/custom_require.rb:31:in `gem_original_require': no such file to l
oad -- rdoc/rdoc (LoadError)
from ./lib/rubygems/custom_require.rb:31:in `require'
from ./lib/rubygems/commands/setup_command.rb:352:in `run_rdoc'
from ./lib/rubygems/commands/setup_command.rb:247:in `install_rdoc'
from ./lib/rubygems/commands/setup_command.rb:120:in `execute'
from ./lib/rubygems/command.rb:257:in `invoke'
from ./lib/rubygems/command_manager.rb:132:in `process_args'
from ./lib/rubygems/command_manager.rb:102:in `run'
from ./lib/rubygems/gem_runner.rb:58:in `run'
from setup.rb:35


Searching through Google got me nowhere – folks were pointing at environment settings, but that was not the problem.

Looks like rdoc was something that was missing. I asked my buddy, who is a Ruby developer and got a hint to do the following:

Install ruby-rdoc, ruby-ri, zlib, zlib-devel

So I did:


[root@centos5 ~]# yum install rdoc ri zlib zlib-devel


After the successful installation of these components and their dependencies I retried to install Gems and …Bingo!


[root@centos5 rubygems-1.3.5]# ruby setup.rb
RubyGems 1.3.5 installed

?=== 1.3.5 / 2009-07-21

Bug fixes:

* Fix use of prerelease gems.
* Gem.bin_path no longer escapes path with spaces. Bug #25935 and #26458.

Deprecation Notices:

* Bulk index update is no longer supported (the code currently remains, but not
the tests)
* Gem::manage_gems was removed in 1.3.3.
* Time::today was removed in 1.3.3.

------------------------------------------------------------------------------

RubyGems installed the following executables:
/usr/bin/gem





5 Responses to “How to install Ruby and Gems on CentOS 5.5”

  1. thanks, been staring at the screen for daze(days)

     
    • nataku
    • Reply
  2. Brilliant – thank you :-)

     
    • Andy
    • Reply
  3. Perfect. Worked on 5.6. Thanks.

     
    • Pablo
    • Reply
  4. I meet this problem like the page http://tickets.opscode.com/browse/CHEF-862
    any help?

     
    • kewin
    • Reply
  5. Thanks dude – also after which executing the following command will keep you up-to-date:

    # gem update –system

     
    • flexinfo
    • Reply

Leave a Comment

*

© 2011 Betaquest, LLC