Could not find gem rack locally or in a repository

I was trying to install Ruby on Rails Gem and it is failed with error of “could not find gem rack locally or in a repository”.

–Error–
===================
[email protected] [~]# gem install rack
ERROR:  could not find gem rack locally or in a repository
===================

I did try to overcome the issue and found out there are two solutions for it.

Solution 1:
Change the gem source.

To show the gem source installed in the server,
===================
[email protected] [~]# gem source
*** CURRENT SOURCES ***

http://gems.rubyforge.org/
===================

1. Change the gem source to allow http://rubygems.org/.
===================
[email protected] [~]# gem sources -a http://rubygems.org/
http://rubygems.org/ added to sources

===================
2. Check the gem source again and it is added.
3. Install your gem again.
===================
[email protected] [~]# gem install rack
===================

Solution 2:
Download the Gem source to your server and install it locally and let say I am referring to rack gems.

Download the source file from URL below.
http://rack.rubyforge.org/

===================
[email protected] [~]# wget http://rubyforge.org/frs/download.php/71197/rack-1.2.0.tar.gz
[email protected] [~]# tar zxf rack-1.2.0.tar.gz
[email protected] [~]# gem install rack

===================

Ruby on Rails Handy Guide

Some Useful command
To install ruby Gem,
gem install [gem_name]
eg, gem install rails

To install ruby Gem with certain version,
gem install [gem_name] –version=x.x.x
eg, gem install rails –version=2.3.5
eg, gem install rails -v=2.3.5

To update ruby Gem,
gem update [gem_name]
eg, gem update mysql

To update ruby Gem with latest version(for all)
gem update –system

To check missing gem
rake gems:install (must run from rails apps folder)

To install gem with lesser space
gem install –no-rdoc –no-ri [gem_name]
eg. gem install –no-rdoc –no-ri rails

To check RoR log,
Path: /home/[cpanel_username]/etc/rails_apps/[apps_name]/log

Continue reading Ruby on Rails Handy Guide