Setting up the Development Environment on MacOS
Last updated: Aug 5, 2024
The following guide is based on MacOS Ventura (13.0).
Overview
- Install Homebrew
- Create SSH keys
- Install Ruby and Rails
- Install Chrome and VS Code
Step 1: Install Homebrew
Homebrew is a package manager for MacOS.
Install it by copying the following command into a terminal window:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Agree to install XCode Command Line Tools if the installer asks. Read the installer's output, and follow any other instructions provided, such as adding Homebrew to your PATH.
Step 2: Create SSH keys
Create an SSH private-public key pair to facilitate logging in to remote machines without typing a password. Copy the command below, customizing login@hostname with your own information.
$ ssh-keygen -t ed25519 -C "login@hostname"
When prompted, accept the default location (~/.ssh/id_ed25519
)
and default passphrase (i.e., empty for none).
Step 4: Install Ruby and Rails on the Virtual Machine
-
Install rbenv as well as ruby-build (a plugin for installing Ruby).
$ brew install rbenv ruby-build
After installation, add rbenv to the shell.
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc $ source ~/.zshrc
-
Install Ruby.
$ rbenv install 3.3.3 # this step takes several minutes $ rbenv global 3.3.3 # set default ruby version $ ruby -v # confirm it works
-
Install Rails.
$ gem install --no-document rails -v 7.0.8
-
Confirm Rails installation with a simple smoke test.
$ mkdir rails_work $ cd rails_work $ rails new demo $ cd demo $ rails server
The output of the last command should look something like:
=> Booting Puma => Rails 7.0.8.y application starting in development => Run `bin/rails server --help` for more startup options Puma starting in single mode... * Puma version: 5.6.8 (ruby 3.3.3-pxx) ("Birdie's Version") * Min threads: 5 * Max threads: 5 * Environment: development * PID: 18440 * Listening on http://127.0.0.1:3000 * Listening on http://[::1]:3000 Use Ctrl-C to stop
You can kill the server with Ctrl-C (in the terminal window in which it is running):
^C- Gracefully stopping, waiting for requests to finish === puma shutdown: yyyy-mm-dd hh:mm:ss -0400 === - Goodbye! Exiting
-
Install Node (not needed for Rails, but we'll be using it too).
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash $ nvm install 20 --lts
Step 5: Install Chrome and VS Code
-
(Optional) Install Chrome. (This step is optional because Safari can be used instead.)
-
Install VS Code.
-
Download and install VS Code for MacOS.
-
Watch the first few overview videos to learn your way around the IDE.
-
Install some useful extensions:
-