mydomain
No ADS
No ADS

Install Ruby and Ruby On Rails on Ubuntu

  1. Ruby & Ruby On Rails
  2. Install RVM
  3. Install Ruby
  4. Install Rails
  5. Appendix: Fix error

1. Ruby & Ruby On Rails

In the post, I explain to you how to do set up Ruby and Ruby On Rails on the Ubuntu OS, note that you can just install Ruby in case you don't need a Framework to programme web.
Ruby is a general-purpose programming language.
Ruby On Rails is a framework written in Ruby that helps web applications to be easier.

2. Install RVM

No ADS
RVM stands for "Ruby Version Manager". RVM provides an efficient way to set up Ruby with a certain version on Ubuntu, normally we will set up the latest version of Ruby.
Firstly, you need to install cURL and gnupg2:
sudo apt-get install curl

sudo apt-get install gnupg2
Install RVM:
Before installing RVM first you need to import public key to your system then use cURL to install RVM.
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3


curl -sSL https://get.rvm.io | bash -s stable
After installing the RVM, you need to close the current Terminal window and open another Terminal window to operate.
Install all the dependencies for installing Ruby automatically on system using below command.
rvm requirements
You can now use the command to list the versions of Ruby that have been released:
rvm list known

3. Install Ruby

No ADS
Use the following statement that helps you to know what versions Ruby currently have.
rvm list known
We will install the latest version.
rvm install 2.4.0
Specify the default version to use.
In the step above, you have already installed Ruby, note that you can install one or more different Ruby versions on the Ubuntu. You need to specify the default version to use:
rvm use 2.4.0 --default
Note: If you detect the following error, you can see how to fix it in the end of this post.
RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
Check the version:
Run the following statement to check what the default Ruby version used is:
ruby --version

4. Install Rails

No ADS
In order to install the latest version of "Ruby on Rails", you need to run the following statement:
gem install rails

rails -v
Or install a specific version:
gem install rails --version=5.0.2
In order to know what versions "Ruby on Rails" currently have, you can look up here:
Check the Rails version you have just installed.

5. Appendix: Fix error

No ADS
If you detect the certain error after specifying the default Ruby version to use:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
  • Edit/Profile Preferences
Close the current Terminal window, and open a new Terminal window to operate.
No ADS
No ADS