FullStack Bootcamp Logo

Setting up your Ruby on Rails dev environment: Ubuntu.

January 27, 2020

So, you want to start developing with Ruby on Rails and React JS in your Ubuntu machine? Let me give you a step-by-step guide on how you can setup your machine.

What are we installing?

  • Node and npm, with NVM
  • Yarn
  • Git
  • Docker
  • Ruby, with RVM
  • Foreman
  • bundle
  • Rails, with React

(We won’t be setting up React individually. We’ll use React within a Rails install.)

Simple Rails Setup with Postgresql

You can go the usual route of setting up Rails, Postgresql, without using Docker. There are already many resources out there how to do this. Here’s a list of some that you can follow:

Whether you’ll be joining or following FullStack bootcamp, you can use these guides if you want a simple Rails install with Postgresql.

Step 1: upgrade all packages

First step is to upgrade and update all packages to the latest versions:

$ sudo apt-get upgrade

Step 3: Node JS through NVM

NVM is Node JS’ version manager. With NVM, you can switch Node versions on the fly. It also automatically does some setup steps for you.

Both Ruby on Rails and React JS requires Node Js installed.

Let’s install nvm by downloading and running the bash script:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

Oh, and also do this:

$ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

note: It’s one whole line.

Confirm that you have nvm installed:

$ nvm -v

Now that we have NVM set up, let’s install Node v12.14:

$ nvm install 12.14

To see installed Node versions:

$ nvm ls

If you have multiple Node versions installed, you can specify which version to use by doing:

$ nvm use 12.14

Step 4: Yarn

Node already has its own package manager with npm, but we prefer using yarn as it compiles way faster than npm.

We’ll first update our package repository:

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Then, install it with apt-get:

$ sudo apt update && sudo apt install yarn

That’s it! To check for yarn’s successful install:

$ yarn -v
# it should yield the version number of Yarn
1.21.1

Step 5: Install git

Ahh git, the universal version control system of developers. Yes, we will be needing this a lot.

Install git with the package manager:

$ sudo apt-get install git

After that, let’s setup your git config:

# set your name
$ git config --global user.name "Your Full Name"
$ git config --global user.email "youremail@provider.com"

Step 6: Simple database with sqlite

We will start off the bootcamp using sqlite as our database system. But, moving forward, we will be using Postgresql instead. But, we won’t install it the usual way. Scroll down to the bottom to find out how we’ll setup postgresql.

Install sqlite is as easy as:

$ sudo apt-get install sqlite3

Step 7: Ruby with RVM

Ruby has multiple version managers with RVM, or RBenv. We prefer using RVM as it’s more stable.

Install gnupg with:

$ sudo apt-get install gnupg2

After that, install the gpg keys:

$ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Once done, install RVM with latest stable version of ruby:

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

Step 8: Install Rails

Now that we have Ruby in our machines, let’s now install Rails. We will be using Rails version 5.2.4 throughout the course of our bootcamp, so we’ll install that version of rails.

$ gem install rails -v 5.2.4

Step 9: Test your dev environment out!

Whew. That was a lot of steps to take. And now, we’re finally at the end. We want to see if our setup is correct.

Let’s first create a directory for all the apps we will be making:

$ mkdir ~/apps

Go to the new directory you’ve just made:

$ cd ~/apps

Create a new rails project:

$ rails new myapp

Go inside the project:

$ cd myapp

Start the project:

$ rails server
# for the shorthand way
$ rails s

On your browser go to: http://localhost:3000

IF you see this: Rails successful install

Congrats! You’ve setup everything properly.

Bootcamp dev environment

TsekAsia’s development team is an avid fan of Docker, and Foreman.

Docker allows use to containerize our development environments, but we won’t use it for that purpose. We will use docker with docker-compose so we won’t have to install and setup other dependencies such as postgresql and redis.

Foreman is a Procfile-based application manager. It allows us to run multiple services all at the same time. We can run, $ rails s, $ docker-compose up, and $ bin/webpack-dev-server start all at the same time, in one terminal window.

We would like to focus more on learning how to use and harness Ruby on Rails with React to its fullest and mitigate the setup process for your development environment. This will also lessen setup time for each individual projects. This would mean, we could focus more on the lessons at hand.

(This is also our Engineering team’s development environment. Following these steps would not only give you a leaner development environment, you’ll also know some trade secrets on how to make your life easier.)

If you will be using Docker for your dev environment, please do not install postgresql through, $ brew install postgresql as this will conflict with the docker instance of postgresql. Specifically, your machine will prioritize allocation of port 5432 to your local postgreql install.

With this, let’s go ahead and set up other development dependencies!

Docker

Docker already has this guide in their website and it’s comprehensive enough that I don’t need to explain it here. But, Here’s the link to their setup guide for MacOS.

Docker CE: https://docs.docker.com/install/linux/docker-ce/ubuntu/

Docker Compose: https://docs.docker.com/compose/install/

Click on the Linux tab in Install Compose section

We won’t be using Docker with docker-compose up until the latter parts of the Bootcamp, but it’s cool to have this installed already so we won’t need to later on.

Foreman

We won’t be using foreman up until the middle of the bootcamp, but it’s better to have it installed now.

Install foreman by doing this,

$ gem install foreman

Test it out by going to the rails app a rails app, and create a file in your root directory Procfile with the following contents:

app: rails s

Once saved, run:

$ foreman start

And you’re all good to go!

Marc Dagatan

Marc Dagatan
Chief Technical Officer
FullSuite

|

FullStack Bootcamp is offering a free coding bootcamp.
What are you waiting for?

Apply now!

Bootcamp Signups are now closed

Thank you for the overwhelming support!

We've received hundreds of signups and we really appreciate all the love.

Reach Us.

We love coffee, do you?

Facebookfb.com/BootCampFullStack
LinkedInlinkedin.com/company/campfullstack
Emailfullstackbootcamp@gmail.com
{
}