Installing Rails 6 on Ubuntu can be tricky. In 5 easy steps, I’ll show you how to do it. I’m currently a web development student at . As part of the curriculum, we’re expected to solve some Rails exercises from . microverse microverse The Odin Project I wrote this article as a way to help my fellow students. This may also help anybody interested in learning Rails. microverse Currently, The Odin Project of Rails (5.2.3). Installing this older Rails version is easy. But as Rails 6 catches on, the older version is bound to fall out of use. uses an older version It took me quite a while to figure out how to do this on my own. This article is meant to save you a couple of hours. That way you can get to work on the fun stuff sooner! Anyway, here’s how I installed Rails 6: Step 1. Prerequisites I installed Rails 6 on running on , but this HOWTO will probably also work for later Ubuntu and Xubuntu versions. Xubuntu 18.04.4 LTS Virtual Box 6.1.2 You can follow the from The Odin Project to set up your preferred Ubuntu distro. You can also install Ubuntu on a real machine if you prefer. Virtual Machine installation guide Step 2. Install rbenv and Ruby The from The Odin Project currently uses Ruby 2.6.5. For Rails 6 we can install up to Ruby 2.7. , Ruby 2.7 has been known to cause warning messages when used with Rails 6. If you don’t really need the latest Ruby version, you can use instead. This might save you a few warning messages later on as you work with rails. Ruby installation guide However 2.6.3 Open your terminal, and run the following set of commands $ sudo apt-get update $ sudo apt-get install curl git nodejs gcc make libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev g++ libpq-dev $ git https://github.com/rbenv/rbenv.git ~/.rbenv clone $ ‘ PATH=” /.rbenv/bin: ”’ >> ~/.bashrc echo export $HOME $PATH $ ‘ “$(rbenv init -)”’ >> ~/.bashrc echo eval $ exit These will install rbenv and close your terminal window. You will need to open a new terminal window for the PATH changes to take effect. To install Ruby 2.7.0, open a new terminal, and enter these commands: $ mkdir -p “$(rbenv root)”/plugins $ git https://github.com/rbenv/ruby-build.git “$(rbenv root)”/plugins/ruby-build clone $ rbenv install 2.7.0 --verbose $ rbenv global 2.7.0 This is probably the most time-consuming part of the HOWTO, so be patient. Once Ruby is done installing, you’ll be ready for the next step. Step 3. Install Rails This step is pretty straight-forward. Instead of installing the older version of Rails, as detailed , we’ll simply install Rails 6.0.2.2: in The Odin Project Guide $ gem install rails -v 6.0.2.2 Step 4. Required additional components When I first tried to install Rails 6 on my virtual machine, I thought the previous step would be all there was to it. But I was wrong! At this point, if you try to run something like rails new my_first_rails_app you’ll get a series of error messages. To fix this, you’ll have to install these recent versions of the following components: Step 4.a. Nodejs To install the nodejs version required by Ruby 6, run: $ curl -sL https://deb.nodesource.com/setup_12.x |sudo -E bash - $ sudo apt-get install -y nodejs $ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - Step 4.b. Bundler and pg Bundler will allow you to load the necessary dependencies from Gemfiles, which are used by Rails apps. Pg is a Ruby gem you’ll need to communicate with PostgreSQL. To install these, do: $ gem install bundler:2.1.4 $ gem install pg Step 4.c. Yarn You will need yarn to be able to run rails server and test your Rails 6 apps. To install the necessary version, run: $ “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list echo $ sudo apt update && sudo apt install yarn $ yarn install --check-files Step 5. Test Rails Finally, you’ll want to make sure everything works as intended. To do this, I suggest you clone and run some tests on it. This repository contains we did from The Odin Project at microverse: my Toy App Github repository one of the first Rails exercises $ git https://github.com/voscarmv/toy_app clone $ toy_app cd $ bundle install $ rails db:migrate $ rails server This should serve the Toy App homepage to Play around with it and see how it works. http://localhost:3000/ NOTE: If you run into errors when running bundle install, try running yarn install --check-files again. That will likely fix the problem. If you decided to use Ruby 2.7 You might be getting warning messages when running or any other rails command. I suggest you point to the 6-0-stable branch of the rails 6.0.2.2 gem in your Gemfile. rails c Your Gemfile should look something like this: Conclusion and acknowledgments I hope this HOWTO helped you save some time. If you run into trouble while trying it out, leave a comment or . I’ll do my best to help you out! contact me on Twitter Finally, a special thank you to my coding partner for helping me find most of the commands from Step 4. I wouldn’t have been able to finish this guide so soon without his help! Alexis