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/rbenvNow let's get rbenv and ruby-build packages from Homebrew, they'll be useful.
brew uninstall --force rbenv ruby-buildThen quit all your opened terminal windows (Cmd + Q) and restart one. Then run:
brew install rbenvAgain, 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.3Once 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.3Then restart your Terminal again (close it and reopen it).
ruby -vYou 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 nowAll, please run the following line:
gem install rake bundler rspec rubocop rubocop-performance pry pry-byebug hub colored octokitNever 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 postgresqlOnce you've done that, let's check if it worked:
psql -d postgresIf 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.