FullStack Bootcamp Logo

Setting up your Ruby on Rails dev environment: MacOS.

January 27, 2020

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

What are we installing?

  • Xcode
  • Homebrew
  • 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. Xcode

If you haven’t installed Xcode yet, this is the first step you need to do.

It’s as easy as going to the App Store and downloading XCode.

Or, in the terminal:

$ xcode-select --install

Step 2: macOS package manager, Homebrew

After installing Xcode, we will download macOS’ package manager, Homebrew.

Open up a terminal and put this in:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Test it out by downloading wget, which we also need.

$ brew install wget

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 first:

$ brew install nvm

Next, create a directory for nvm:

$ mkdir ~/.nvm

We also need to add a few lines to ~/.bash_profile to make nvm executable:

$ export NVM_DIR=~/.nvm
$ source $(brew --prefix nvm)/nvm.sh

Running nvm -v should yield you the ff:

as-MacBook-Pro:fullstack-web marcdagatan$ nvm -v
Node Version Manager (v0.35.1)
# More info about Node Version Manager

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 again use brew to install Yarn:

$ brew install yarn

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

$ yarn -v
# it should yield the version number of Yarn
as-MacBook-Pro:fullstack-web marcdagatan$ yarn -v
1.21.1

Step 5: Install git

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

Let’s first install git, again with brew:

$ brew 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:

$ brew 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.

Let’s first install gpg with brew:

$ brew install gnupg

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.

https://docs.docker.com/docker-for-mac/install/

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
{
}