Ruby Installation - Linux

The steps to install Ruby on a Linux machine are listed below.

Note: Make sure you have root privileges before installing.

Source installation

  • Download the latest version of Ruby zip file. Click here to download.
  • After downloading Ruby, unzip it into the newly created directory:
$ tar -xvzf ruby -2.2.3.tgz
$ cd ruby-2.2.3
  • Now, configure and compile the source code as follows:
$ ./configure
$ make
$ sudo make install
  • After installation, make sure everything is working by entering the following command on the command line:
$ruby -v
Ruby 2.2.3...
  • If everything is working fine, the version of the installed Ruby interpreter will be output, as shown above. If you have a different version installed, a different version will be displayed.

Automatically install Ruby

If your computer is already connected to the Internet, the easiest way to install Ruby is to use yum or apt-get. You can install Ruby on your computer by entering the following command at a command prompt.

$ sudo yum install ruby ​​# CentOS, Fedora, or RHEL system 


Sudo apt-get install ruby-full # Debian or Ubuntu System

If you are an Apple system, you can install it using the brew command:

$ brew install ruby

Install Ruby using RVM

RVM can install and manage multiple Ruby versions on your system. It also manages different gem sets. Support for OS X, Linux, and other UNIX-like operating systems.

Install RVM

$ gpg --keyserver Hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ curl -sSL https://get.rvm.io | bash -s stable

After the installation is complete, some installation information will be listed, one of which should be noted:

To start using RVM you need to run `source /etc/profile.d/rvm.sh`

meaning that if you want to start using a source command to re-execute the newly modified initialization file, according to the installation prompt, execute the following command to load the RVM environment (the new Termal does not need to do this, it will be automatically reloaded) )

source /etc/profile.d /rvm.sh

Check if it is installed correctly

$ rvm -v
rvm 1.22.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Installing a Ruby environment with RVM

List the known ruby ​​versions:

$ rvm list known

You can choose an existing rvm version to install (the following is an example of rvm 2.4.2 installation)

$ rvm install 2.4. 2

Also continue to wait for the long download, the compilation process, after the completion, Ruby, Ruby Gems is installed.

rvm common command

Query the installed ruby

$ rvm list

Uninstall an installed version

$ rvm remove 1.9. 2

Setting the Ruby version

After RVM is installed, you need to execute the following command to set the specified version of Ruby to the system default version

$ rvm 2.0.0 --default

Also, you can use other version numbers, provided you have installed that version with rvm install

This time you can test if it is correct

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]

$ gem -v

This is probably because Ruby's default source is cocoapods.org. There are sometimes problems with accessing this URL in the country. One solution on the Internet is to replace the far with ruby-china, as follows: /p>

$ gem source -r Https://rubygems.org/
$ gem source -a https://gems.ruby-china.com/

To verify that the replacement was successful, you can execute:

$ gem sources -l 

Normal output:



Please make sure that only gems.ruby-china.com

$ gem install rails

If you use Gemfile and Bundle (for example: Rails project)

You can mirror commands with Bundler's Gem source code.

$ bundle config mirror. Https://rubygems.org https://gems.ruby-china.com

This way you don't have to change the source of your Gemfile.

source 'https://rubygems.org/'
Gem 'rails', '4.1.0'

Cloud Studio

Cloud Studio is a browser-based, integrated development environment that supports most programming languages. Including HTML5, PHP, Python, Java, Ruby, C/C++, .NET, etc., you don't need to download the installer, switch the development environment with one click. Cloud Studio provides a complete Linux environment and supports custom domain name pointing, dynamic computing resource tuning, Complete development, compilation, and deployment of various applications.

Now CODING is hosting a [My Favorite Cloud Studio Plugin Selection Contest] based on the Cloud Studio workspace. Go to the event website: https://studio.qcloud.coding. Net/campaign/favorite-plugins/index for more event information.

welookups is optimized for learning.© welookups. 2018 - 2019 All Right Reserved and you agree to have read and accepted our term and condition.