Welcome to the Rails DeCal!

We are super excited to get started this semester and we have a lot to cover in 10 weeks. This homework is to help you get set up with some of the basic tools we will be using this semester.

Don't worry if you don't finish. We will be helping helping people out during lab on the first day.

There are four parts to this homework:


There is no submission for this homework


Installing Homebrew (MacOS only)

Homebrew is a package manager that simplifies the installation of software through the command line interface

Step 1: Installing Command Line Tools for Mac OS

  1. Launch the Terminal, found in /Applications/Utilities/

  2. Type the following command string:

    xcode-select --install
    
  3. A software update popup window will appear that asks: “The xcode-select command requires the command line developer tools. Would you like to install the tools now?” choose to confirm this by clicking “Install”, then agree to the Terms of Service when requested (feel free to read them thoroughly, we’ll be here)

  4. Wait for the Command Line Tools package download to complete, it’ll be about 130MB and installs fairly quickly depending on your connection speed.

Step 2: Install Homebrew

Homebrew, "the missing package manager for OS X," allows you to easily install hundreds of open-source tools. The full installation instructions are available in the Homebrew Documentation, but you should only need to run the command that's listed at the top of the Homebrew site.

Run this command inside your terminal:

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

Once the installation is successful, run the following command:

brew doctor

If you get Your system is ready to brew, you can move on to Step 3. Otherwise, go to the call an instructor to help troubleshoot. (Page to troubleshoot)

Installing Windows Subsystem for Linux (Windows only)

Windows Subsystem for Linux (WSL) is a Windows 10 feature that allows running native Linux command-line tools possible directly on Windows

Step 1: Enabling the "Windows Subsystem for Linux" feature

  1. Search for "PowerShell" in the Start menu

  2. Right click and select "Run as an administrator"

  3. Type the follow command string:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    
  4. Restart your computer when prompted

Step 2: Install the Linux Distribution

  1. Open the Microsoft Store and search for "Ubuntu"
  2. Install the first search item called Ubuntu

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4a7b7225-c46c-4df1-ada8-216a2c5e242b/ubuntu_download.png

Step 3: Initialize Ubuntu

  1. Open the newly installed Ubuntu app

  2. You will be prompted to create a new user account with a password

    1. You can choose any username and password. They are separate from your Windows username
    2. Make sure to remember your password as you will need it for sudo when you elevate a process
  3. Update and upgrade your packages

    sudo apt update && sudo apt upgrade
    

Installing Ruby and Rails

MacOS

Step 1: Installing Rub

We will be using rbenv for our ruby version manager

brew install rbenv ruby-build

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

# Install Ruby
rbenv install 2.6.3
rbenv global 2.6.3
ruby -v

After the last command you should see something like the following

ruby 2.6.3p62

Step 2: Installing Rails


gem install rails -v 6.0.0
rbenv rehash
rails -v

After the last command you should see something like the following

Rails 6.0.0

Windows

Step 1: Installing Ruby

  1. Install necessary dependencies for Ruby. Since we just updated our package library, we don't need to do sudo apt update again, but it is a good idea to always run the command before installing a new package to ensure an up-to-date installation.

    sudo apt-get install git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
    
  2. We will be using rbenv for our ruby version manager

    cd
    git clone <https://github.com/rbenv/rbenv.git> ~/.rbenv
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
    exec $SHELL
    
    git clone <https://github.com/rbenv/ruby-build.git> ~/.rbenv/plugins/ruby-build
    echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
    exec $SHELL
    
    rbenv install 2.6.3
    rbenv global 2.6.3
    ruby -v
    

    After the last command you should see something like the following

    ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
    
  3. Install bundler which is a package manager for Ruby projects

    gem install bundler
    rbenv rehash
    

Step 2: Installing Rails

  1. In order to use the dependencies that Rails ships with, we need to install NodeJS, which is a cross-platform JavaScript runtime

    curl -sL <https://deb.nodesource.com/setup_8.x> | sudo -E bash -
    sudo apt-get install -y nodejs
    
  2. We can now finally install Rails

    gem install rails -v 6.0.0
    rbenv rehash
    rails -v
    

    After the last command you should see something like the following

    Rails 6.0.0
    

Installing Git

Git is the version control system of choice among many web developers.

MacOS

Install Git

brew update
brew install git

Since we just installed Homebrew, we could have skipped brew update, but it's a good habit to run it before installing anything with Homebrew because Homebrew is updated regularly.

To verify:

git --version

You should get git version 2.23.0 or later.

Run brew doctor to make sure everything is still working. If your system is ready to brew, you can move on.

Windows

We installed Git when installing the large list of dependencies before installing Ruby.

You can verify with:

git --version

You should get git version 2.17.0 or later.

Configure Git with GitHub

Most of the time when we edit code we want to store it in GitHub so that we can have others see and or contribute to our code as well as get credit for out work so lets configure out Git to have it linked to our GitHub. If you do not have a GitHub account make an account by clicking here.

  1. Configure your git setting to match GitHub

    git config --global user.name "Your name here"
    git config --global user.email "[email protected]"
    
    

    Make sure the email you use is the email associated with your GitHub account.