How to Install Ruby 2.6 & Rails 6 on Ubuntu 19.04

In this tutorial, we'll see how we can install the latest version of Ruby v2.6 on Ubuntu 19.04 Disco Dingo. and next we'll see how to set up a development environment for Ruby on Rails 6.

As of this writing, the current stable version of Ruby is v2.6.3.

How to Install Ruby 2.6 on Ubuntu 19.04?

You can install Ruby 2.6 on Ubuntu 19.04 using three different methods:

  • Using rbenv
  • Using RVM or Ruby Version Manager
  • From the source

So let's use rbenv.

Installing Ruby 2.6 with rbenv

You first need to install rbenv and then use it to install Ruby v2.6.

Open your terminal and run the following command:

$ git clone ~/.rbenv

We simply clone rbenv GitHub repository into the ~/.rbenv folder.

You need to have Git installed on your system. If not, simply run sudo apt install git from your command line.

Next, run the following commands to set up rbenv:

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL

Next, you need to download the ruby-build plugin into the plugins folder of rbenv as follows:

$ git clone "$(rbenv root)"/plugins/ruby-build

The ruby-build plugin adds the install command to rbenv.

Note: You can also install rbenv and ruby-build using the sudo apt-get install rbenv ruby-build command.

Finally, you can install Ruby 2.6.3 using the following command:

$ rbenv install 2.6.3
$ rbenv global 2.6.3

This is the output in the terminal:

Downloading ruby-2.6.3.tar.bz2...
Installing ruby-2.6.3...
Installed ruby-2.6.3 to /home/<user_name>/.rbenv/versions/2.6.3

If your installation fails, make sure you install the libreadline-dev and zlib1g-dev dependencies:

$ sudo apt-get install -y libreadline-dev zlib1g-dev

You can check out your Ruby version using the following command:

$ ruby -v

Next, you need to install bundler with gem:

$ gem install bundler

This will install bundler v2.0.2.

After installing bundler, you need to run:

$ rbenv rehash

Installing Ruby on Rails 6 on Ubuntu 19.04

After installing Ruby 2.6, let's now see how we can install Ruby on Rails 6.

As of this writing, Rails 6.0.0.rc1 is released. Let's see how to install it. Open a new terminal and run the following command:

$ gem install rails -v 6.0.0.rc1

Next, run the following command to make the rails executable available:

$ rbenv rehash

That's it! You can verify your installed Rails version by running the following command:

$ rails -v
# Rails 6.0.0.rc1

Congratulations! You have set up your development environment for Ruby on Rails 6 development.

Note: We also publish our tutorials on Medium and If you prefer reading in these platforms, you can follow us there to get our newest articles.

You can reach the author via Twitter:

About the author

Ahmed Bouchefra
is a web developer with 5+ years of experience and technical author with an engineering degree on software development. You can hire him with a click on the link above or contact him via his LinkedIn account. He authored technical content for the industry-leading websites such as SitePoint, Smashing, DigitalOcean, RealPython, freeCodeCamp, JScrambler, Pusher, and Auth0. He also co-authored various books about modern web development that you can find from Amazon or Leanpub

Get our Learn Angular 8 in 15 Easy Steps ebook in pdf, epub and mobi formats, plus a new Angular 8 tutorial every 3 days.

Online Courses (Affiliate)

If you prefer learning with videos. Check out one of the best Angular courses online
Angular 8 - The Complete Guide (2019+ Edition)

Angular Crash Course for Busy Developers

comments powered by Disqus Protection Status