The Instructions below are for installing on Mac, if installing on Linux or Windows use the following:

Ruby - Environment

⚠ Uninstall RVM (Ruby Version Manager)

To check if you have RVM installed simply run the command rvm. If it is not intalled you'll see the message command not found: rvm

If it is installed then uninstall rvm by following these instructions:

Once you have removed rvm close and reopen the terminal. Then test running the rvm command and confrim it's been removed.

Homebrew

Confirm Homebrew Install

  • See if brew is already installed by typing:
brew -v

You should get a message similar to the following:

Install Homebrew

  • If Homebrew is not installed then copy/paste this into the terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Homebrew Installed Already

  • If brew is installed, run brew upgrade to upgrade to the latest version of homebrew

    • Might take a while, might upgrade stuff for postgres, node, heroku, etc.
  • Run brew update to update the list of installable programs by homebrew

    • Might say Already up-to-date

Install rbenv

rbenv is a version manager for Ruby. We don't want to use our system Ruby because we can mess with it. Instead, let's get an up to date version of Ruby that is safe to mess with.

  • Check if rbenv already installed: rbenv
  • If already exists, upgrade with:
brew upgrade rbenv ruby-build

Otherwise:

brew install rbenv ruby-build

View Possible Ruby Versions

See which versions of Ruby you can download

rbenv install --list

There will be stuff like rbx and jruby, we are only interested in the ones that start with numbers.
You should see outputs similar to the following:

Or you can try using the rbenv install --list-all command to list all the versions. In the middle of the list, you will see outputs like:

Either command is fine, you need to choose the version of ruby before jruby-someversion or -dev

Install Latest Ruby

Install the latest version of Ruby

At the time of updating this readme the current version was 3.0.1.

rbenv install 3.0.1
  • There is no way within rbenv just to get the latest stable version
  • You must install Ruby 3.0.1 or greater for Rails 6.
  • Install might take a long time -- Terminal could just look like it's hanging

ruby-build: use readline from homebrew

Installed ruby-3.0.1 to /usr/local/var/rbenv/versions/3.0.1

View Installed Versions of Ruby

rbenv versions

  • system is your system Ruby
  • asterisk is next to the version that you are using

View Currently Running Version of Ruby

rbenv version

Switch rbenv to a different Version of Ruby

rbenv global 3.0.1

Check with rbenv versions. Asterisk should be next to 3.0.1

Tell the computer we've switch versions of ruby and confirm:

rbenv rehash

rbenv versions

CLOSE AND RESTART TERMINAL

Update Environment to use new Ruby

Confirm ruby version now in use by the system is 3.0.1 or something similar

ruby -v

IF NOT

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
  • (replace .bash_profile with .zshrc if you're using zsh)
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
  • (replace .bash_profile with .zshrc if you're using zsh)

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile * (replace .bash_profile with .zshrc if you're using zsh) Close and repoen the terminal and confirm ruby version now in use by the system is 3.0.1 or something similar

ruby -v

Install a gem

Gems are like NPM packages for Ruby, but they're installed globally, as opposed to multiple times for each application that you build.

The steps below will confirm that you are able to install a gem. The gem is called pry which is one of the available ruby terminal shells we can use to run ruby commands via the terminal.

  1. List gems with gem list
  2. Run gem install pry to install a gem called pry. It's a ruby REPL command
  3. Run rbenv rehash to tell computer we've installed a new gem
  4. List gems with gem list look for pry
  5. Run pry to start pry command
  6. Inside pry type 2 + 2
  7. If that works, type quit

Note:

  • If you are getting a permissions error you can aadd sudo in front of the command for now.
  • Might need to update the gem manager with gem update --system

Install Rails 6

  1. Run gem install rails to install the rails commands
  2. rbenv rehash
  3. rails -v

Note: if Rails already installed, might need to run bundle update rails

Test Rails

  1. Run rails new blog --api to create a new app
  2. cd blog
  3. Run rails s to start the server
  4. Now, everything should be good.
  5. Ready to see something cool? Go to http://localhost:3000

Install Postgres on Mac

Follow the directions HERE