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.

  • You really should use rvm for this, even if you don't want to. – Michael Hampton Feb 3 '15 at 19:16

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:

| improve this answer | |
  • Thank you very much for your answer, Aaron. It's gotten me a step further. After running the command ruby setup.rb --prefix=/usr/local, gem -v doesn't work. However, running ruby setup.rb --prefix=/usr/local does it as gem -v now outputs 1.3.7. I can't explain why this happened. I tried to install rails with gem install rails and I got the following error: – Ralph Feb 3 '15 at 20:22
  • /usr/local/lib/ruby1.8/timeout.rb:60: [BUG] Segmentation fault --linebreak-- ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-linux] -linebreak-- Aborted (core dumped) – Ralph Feb 3 '15 at 20:24
  • Not a lot to go on there, man. – Aaron Copley Feb 3 '15 at 20:57
  • 1
    The problem was with the version of gcc/g++ used to compile the ruby package. I will post a detailed answer later. Thanks for the help, @Aaron Copley. – Ralph Feb 3 '15 at 21:04
  • Good find. If this answer helped you install gem, don't forget to upvote it. – Aaron Copley Feb 3 '15 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.