
How to install a specific ruby version on Linux
Ruby is an open-source programming language with features that this post will not cover. This post focuses on installing a specific version of ruby. This is important where the development process requires a specific version of ruby.
You can download from the repository but that means you won’t be able to get the required version for your project unless the repository version is the required one for your project. To install from the repository,
1. Open a terminal window. The default shortcut is Ctrl + Alt + T
2. Type the command below to check whether Ruby is already installed on your system
ruby -v
if you see something like this, then ruby is not installed on your system
The program ‘ruby’ is currently not installed. You can install it by typing:
sudo apt install ruby
3. The command to install ruby from the repository is
sudo apt-get install ruby-full
4. Running the command ruby -v should now show you the installed version of ruby
To install a specific version of ruby, we are going to use ruby-install
1. Type the command below or copy and paste it into your terminal
wget -O ruby-install-0.6.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.6.1.tar.gz
This downloads the required files to your system
2. To unpack the downloaded file, we use the tar command
tar -xzvf ruby-install-0.6.1.tar.gz
3. Change directory into the unpacked folder for ruby install. The command
cd ruby-install-0.6.1/
This changes the folder path to the ruby-install folder which was -v 0.6.1 at the time of writing this (may have changed)
4. Run the command
sudo make install
which installs ruby-install on your system
The next step is to install the desired ruby version
1. This is pretty straightforward. Use this command and edit to desired ruby version which for this tutorial was ruby 2.3.1
ruby-install ruby 2.3.1
And that’s it!!!
Now sit back and wait for ruby to be compiled
For more information visit their github page on
https://github.com/postmodern/ruby-install#readme