Installing Ruby (with rbenv)
First we need to clean up any previous Ruby installation you might have:
rvm implode && sudo rm -rf ~/.rvm
# If you got "zsh: command not found: rvm", carry on. It means `rvm` is not
# on your computer, that's what we want!
sudo rm -rf $HOME/.rbenv /usr/local/rbenv /opt/rbenv /usr/local/opt/rbenv
Now let's get rbenv
and ruby-build
packages from Homebrew, they'll be useful.
brew uninstall --force rbenv ruby-build
Then quit all your opened terminal windows (Cmd + Q) and restart one. Then run:
brew install rbenv
Again, quit all your terminal windows and restart.
Now, you are ready to install the latest ruby version, and set it as the default version.
Run this command, it will take a while (5-10 minutes)
rbenv install 2.5.3
Once the ruby installation is done, run this command to tell the system to use the 2.5.3 version by default.
rbenv global 2.5.3
Then restart your Terminal again (close it and reopen it).
ruby -v
You should see something starting with ruby 2.5.3p
. If not, ask a teacher.
gem install
command!
# China only!
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.com/
gem sources -l
# *** CURRENT SOURCES ***
# https://gems.ruby-china.com/
# Ruby-china.com must be in the list now
All, please run the following line:
gem install rake bundler rspec rubocop rubocop-performance pry pry-byebug hub colored octokit
Never install a gem with sudo gem install
! Even if you stumble upon a Stackoverflow answer
(or the Terminal) telling you to do so.
In a few weeks, we'll talk about SQL and Databases and you'll need something called Postgresql, an open-source robust and production-ready database. Let's install it now.
brew install postgresql
brew services start postgresql
Once you've done that, let's check if it worked:
psql -d postgres
If you enter a new prompt like this one, you're good!
psql (9.5.3)
Type "help" for help.
postgres=#
To quit it, type \q
then Enter
.