Following are the commands which can be used to install the ruby with rubygems and libyaml:
To install ruby use the following commands:
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194
./configure
make
make install
ruby -v
To check if your ruby is correctly working or not create a test ruby script and run it:
vi test.rb
Use the following code for test purpose: #!/usr/bin/env ruby
puts "Ruby working Fine:)"
Give the ruby script execute permission and run the script to see if ruby is working fine or not: chmod +x test.rb
./test.rb
To install rubygems use the following commands:
wget http://rubyforge.org/frs/download.php/76073/rubygems-1.8.24.tgz
tar -xvzf rubygems-1.8.24.tgz
cd rubygems-1.8.24
ruby setup.rb
gem -v
If you get an error regarding the libyaml dependency, follow the following steps:
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar -xvzf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure
make
make install
Now again install the ruby again, make clean is used to do fresh ruby install after removing the previous one:
cd ruby-1.9.3-p194
make clean
./configure
make
make install
After successful installation you will be getting following outputs:
# ruby -v
ruby 1.9.3p194 (2012-04-20) [x86_64-linux]
# ./test.rb
Ruby working Fine:)
# gem -v
1.8.24