Installing rubygems after manually installing ruby 1.8

repositoryrubyrubygemsubuntu-14.04

I have successfully installed Ruby 1.8.7 on Ubuntu 14.04 by downloading the package, building locally and installing. The command ruby -v, outputs Ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-Linux] as expected, this is the same output on another server running Ubuntu 12.04 where my application is working as expected.

The output of which ruby is /usr/local/bin/ruby on Ubuntu 14.04 and /usr/bin/ruby on Ubuntu 12.04. This gives me the impression that Ruby 1.8 (which is what my application needs) is installed.

However, when I try to install the rails gem: gem install rails (logged in as root; I also installed ruby as root), I get the following error:

The program 'gem' can be found in the following packages:
* ruby
* rubygems 
Try: apt-get install <selected package>

While running apt-get install ruby will fix this, it will install ruby 1.9.x which is not the version I need. I already have the required version installed as stated above.

Running apt-get install ruby1.8 which will work on Ubuntu 12.04, throws up an error on 14.04 because ruby1.8 is a bit outdated and has been removed from the official ubuntu 14.04 repositories, but my application is yet to be ported to the newer ruby versions.

So the question is, how do I install rubygems, specifically version 1.3.7 manually?
Please don't suggest adding the Ubuntu 12.04 repositories back to 14.04, that's a terrible solution and can break the system moving forward. I also don't want to use RVM to accomplish this.
I will prefer to manually configure the system to execute the gem commands under the currently installed 1.8 version located at /usr/local/bin/ruby.

Any help is appreciated.

Best Answer

Download the version you need from Rubygems.org. (1.3.7) Unpack the file and install to your Ruby $PREFIX;

ruby setup.rb --prefix=/usr/local

(That might actually be the default $PREFIX so specifying may be redundant..)

For more information see: Download RubyGems. Scroll down to this section;

If you don't have any RubyGems installed, there is still the pre-gem approach to getting software, doing it manually:

Related Topic