Problem installing ruby and gems

I just installed ruby using apt-get with the following command:

sudo apt-get install ruby1.9.1-full

But when I try to do sudo gem install ... it says that I have not installed gems and that I shoud get rubygems1.9.1, I tried to do so but it said I already have it installed (I believe they are included in ruby1.9.1).

I believe its a problem relating only to ruby because I never had issues installing anything through apt-get and then not getting it recognized. I tried login out, rebooting but no luck. I'm on 10.10 by the way.

Does anyone know what could be wrong?

Thanks in advance!


You have two options.

You can use a script that will do this for you, or you can follow the guide manually - they'll both have the same results, and they'll both do the same thing, the only difference is that the script won't require you to copy/paste anything after you select the method of installation in the script itself.

Keep in mind that the script will update your system and install various dependencies.You will after be asked if you want to install it system-wide [1] or for your local user [2] - if you want to use the same basic method as the guide below, choose [2] To use this script, you simply run the following:

wget --no-check-certificate https://raw.github.com/joshfng/railsready/master/railsready.sh && bash railsready.sh

This is a different way of installing Ruby and gems that while it doesn't necessarily fix your problem per se, it does provide a way for you to get Ruby working on your computer.

  1. Install git and curl. To do that, open a terminal by hitting "Alt-F2", and typing gnome-terminal into the resulting dialog. Next, hit "enter" to launch the terminal. Now, copy and paste the following line into the terminal.

sudo apt-get update && sudo apt-get install git curl -y

Hit enter, and now you can just sit back and relax for a few minutes while it installs.

Download and install RVM. To download and install RVM, use the following line of command-line magic.

 bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Now that you've got that installed, you have to add it to your terminal's path, which tells the terminal where to find all of the commands. To do that, type "gedit ./.bashrc" into your terminal, then past the following line down at the very bottom.

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

Now, close your terminal, and open a new one by typing "Alt-F2" and typing in gnome-terminal.

Now you're ready to install ruby itself. But before you can do that, you have to install all the stuff that you need for RVM to install Ruby. To do that, you have to run the following command.

sudo apt-get update && sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev -y

You're probably asking yourself "What the heck does all THAT do?!!". Well, here's the answer: Mostly has to do with compiling ruby, which you'll do in a second.

To install ruby 1.9.2 (Which is the most recent version as of writing), you need to type the following in your command prompt.

rvm install 1.9.2

hit enter, and then go grab a snack. This step is going to take awhile.

Now that you've taken your last walk for awhile (Or whatever the heck you just did while ruby compiled), it's time to create a gemset.

One of the nicest things about RVM is that it lets you have multiple versions of Ruby installed, something that you'll want to use as you get further along in programming Ruby. So, here's how to create a gemset.

rvm --create use 1.9.2@first-gemset && rvm --default use 1.9.2@first-gemset

Congrats! Now, you can test and see if RVM did it's job by typing in the following line.

ruby -v

It should spit out something like this:

ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]

Congrats! You've got rvm and Ruby installed successfully. Now, you can install Rails (Or any gem) by typing in this:

gem install <gem name>

Note: replace with the name of the gem you're trying to install