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 RVM or Ruby Version Manager
- From the source
So let's use
Installing Ruby 2.6 with
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 https://github.com/rbenv/rbenv.git ~/.rbenv
We simply clone
rbenv GitHub repository into the
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
$ 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 https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
ruby-build plugin adds the
install command to
Note: You can also install
sudo apt-get install rbenv ruby-buildcommand.
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... -> https://cache.ruby-lang.org/pub/ruby/2.6/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
$ 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
$ gem install bundler
This will install
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.
Get our Angular 2+ posts in your inbox