I installed Ruby with the command apt-get install ruby1.9.1, but when I enter ruby in the console, nothing happens.

I have to use the command


ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]

But how do I call it with ruby and not ruby1.9.1? And how do I install Rails?

  • What happens if you do "which ruby", does it show as being installed? Does "ruby -v" show the right version number? Jun 1, 2011 at 20:10
  • Install: sudo apt-get install ruby1.9.1-full ruby -v
    – BILL
    Jun 1, 2011 at 20:13
  • Program 'ruby' is not installed.
    – BILL
    Jun 1, 2011 at 20:13
  • When you type "sudo apt-get install ruby1.9.1-full" in a terminal does anything happen? Jun 1, 2011 at 20:24
  • 1
    I'm a little confused by your update. If you want to install rails please use RVM - rvm.beginrescueend.com - to install rails and any other gems. It is a package manager and will save you a lot of time. Jun 1, 2011 at 21:10

2 Answers 2


How to get a current Ruby version without messing up your system

Do not mess with your system Ruby, but instead install a current version with either rbenv or RVM. I prefer the first, but both work fine. Note that you can only install one of those at a time.

With such a Ruby version manager, you'll never have to type sudo again to install (or uninstall) a Gem, and you can keep different versions for different projects. You can safely remove these versions again.

Please make sure to read the READMEs of those tools, at least once.

Method 1 – rbenv

rbenv is a version manager for Ruby. It allows you to install a Ruby version alongside your original system Ruby, which means you cannot mess up that one, and you can easily upgrade versions.

To install it, use the rbenv-installer. Make sure to restart your shell once it's installed, and that the rbenv function works.

Then, once rbenv is installed, run rbenv install -l. This gives you a list of available Rubies. Install your chosen one with:

rbenv install 2.5.1

Now choose this one as your default:

rbenv global 2.5.1

As soon as this is done, gem can be used to run:

gem install rails

If the above does not work, you might be missing required packages for building from source. See here for a list of packages that you might want to install. On Ubuntu, these include:

sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev

Method 2 – RVM

You can also install Ruby over RVM. Here as well, you don't need to sudo anything, and you'll be able to get more recent versions of Ruby alongside the system one.

Read the installation instructions for your system.

After installation, you can install Rubies with a simple command. First, check rvm list known to get the list of installable versions. Now install your choice:

rvm install 2.5.1

Then, set it as the default Ruby version for your user:

rvm use 2.5.1 --default

Now you can install Rails over gem:

gem install rails
  • Also, if you are using RVM do not use sudo. Jun 2, 2011 at 11:05
  • FYI - in the apt-get install step, you have lib1g above when this should be zlib1g. I also installed rvm with apt-get. This sets things up nicely and doesn't require you to edit your bashrc. I'm not sure if this is the best approach as I haven't tried $rvm get latest yet.
    – spinlock
    Apr 3, 2012 at 17:08
  • @slhck StackExchange won't let me make the edit to the apt-get install step - edits have to be more than 6 chars and we only need to change 1. And, I'm not a fan of sudo apt-get install ruby-rvm so far. I'm getting weird bugs due to permissions (i.e. $rvm install 1.9.3 complains because it's trying to write to a directory owned by root). It looks like keeping rvm in userspace is the best option.
    – spinlock
    Apr 3, 2012 at 18:22
  • I feel like rbenv (and ruby-build) should be mentioned here for completeness. It's an alternative to RVM with a cleaner method of hooking into your shell (but is practically not necessarily very different).
    – JamesGecko
    Apr 3, 2012 at 18:43
  • 1
    I just did sudo apt-get install ruby-rvm -- is there still a need to do the crazy bash stuff to beginrescueend, whatever that is? Jul 18, 2012 at 20:09

There are multiple ways to install ruby on ubuntu, but installing form the repositories is (currently) not popular. To cleanly get a non-suffixed ruby, you should build ruby yourself or use rvm.

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