Skip to content

Instantly share code, notes, and snippets.

@coder-sheep
Last active September 24, 2016 19:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save coder-sheep/bb7767e0597bec353fb4 to your computer and use it in GitHub Desktop.
Save coder-sheep/bb7767e0597bec353fb4 to your computer and use it in GitHub Desktop.
Instructions for installing Ruby and other development tools for use in intro ruby courses.

#Ruby For Beginners : Setup

Greetings Rubyists:

We hope you are excited to learn Ruby. Before the workshop, we need you to set up your development environment with Ruby and a text editor. Choose one of the three options listed below.

  1. Use an online development portal. This is a simple approach and you can do it from a Mac or Windows. You will be able to practice writing Ruby code without installing anything on your computer. At some future time, you will want to get ruby installed and ruby on your machine, but you don't have to for tonight.
    Instructions: Create an account at cloud9.
  2. Install Ruby, Sublime, and Git for a Mac. Skip this step if you can type $ gem install sinatra in your Terminal and install the sinatra gem without any errors.
  3. Install Ruby, Sublime, and Git for Windows Skip this step if you can type $ gem install sinatra in your Terminal and install the sinatra gem without any errors.

##Instructions For Mac

###Release 0: Download Sublime Text

  • Download and follow instructions to install Sublime Text 3 from their site . Make sure to move it to your applications folder.

  • You don't have to purchase your license right away, you can "cancel" out of the dialog box as many times as you would like, but it is good practice to buy a license after you decide you like it. (Since eventually you're hoping to get paid for writing programs, you want to pay it forward in advance.)

###Release 1: Your Operating System###

  • If you are using OS X, you should upgrade to El Capitan or Yosemite if you haven't already. You can get it from the App Store on your computer and it's free. To find out which operating system you're running, open the "About this Mac," Under OS X, you should see a version. El Capitan(10.11) or Yosemite (10.10) - the two latest versions of OS X are recommended.

  • Before installing, it's always good practice to backup your hard drive so you don't lose anything!

###Release 2: Install Command Line Tools Release 2 - 12 will be run in your terminal. If you can't find the terminal, simply search "terminal" in spotlight.

  • Install apple's C compiler which will enable you to compile native apps from source. (i.e. Ruby)
  • In your terminal, type: xcode-select --install
  • Follow the prompts to complete the install.

###Release 3: Install Homebrew

  • Also called "Brew." Homebrew is like the app store for the command line (i.e. your terminal). If you ever need any command-line tool, try installing with Brew before other methods. (ex. brew install name-of-thing)

  • Install brew by copying and pasting this beautiful code into your terminal:

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

  • It will prompt you for your password - so be ready to type it in.

###Release 4: Install Git

  • Type: brew install git

  • This installs git and autocompletion for git.

###Release 5: Configure Git

  • You then need to overwrite .gitconfig to your own username and password in GitHub. Use your name and your GitHub email address in the following format:
git config --global user.name "John Doe"  
git config --global user.email johndoe@example.com

###Release 6: Set up your Path

  • First you need to clone this GitHub repository into your computer and install the files. Type each line separately in your terminal:
git clone https://github.com/supertopher/dotfiles.git 
cd dotfiles
./install
  • Note This will change how your current terminal will appear by changing your .bash_profile file (a file that tells terminal how it should display)

  • Installing these files will configure your bash profile, enable autocomplete, always display rspec with color, and allow you to use "subl" as a shortcut to open sublime.

  • If it runs properly, you will have a new line. The bash convention is to succeed silently, which means to not give a success message, only error messages.

###Release 7: Install Rbenv

  • Type: brew install rbenv Now you have Rbenv! Sweet!

  • NOTE: If you already have RVM installed, you will not need to install Rbenv. Do not try to install both, they don't work well together and will mess up your machine. Rbenv is preferred in many of our locations, so if you have RVM and want to install Rbenv, you'll have to uninstall RVM first. Type which rvm to see if you already have RVM installed.

###Release 8: Install Ruby Build

  • Type: brew install ruby-build

  • Rbenv uses this to install individual versions of Ruby. (Did you know you can have multiple versions of Ruby on your machine?)

###Release 9: Install Ruby 2.3.0

  • Type: rbenv install 2.3.0

  • Now, you need to set the default Ruby in your computer to the Ruby we just installed. Type: rbenv global 2.3.0

  • Restart your terminal

###Release 10: Set up Sublime To Open Your Files from Command Line

  • Now make Sublime Text your preferred editor for git: git config --global core.editor "subl -w”

  • Test by typing subl . This will open your current directory in Sublime if you have linked the Sublime application properly.

###Release 11 - Install Sinatra Gem

  • If the steps above have successfully installed Ruby, you should be able to install gems. Type gem install sinatra. If you don't get any errors, you are good to go!

##Instructions for Windows

The easiest way to get ruby working on a Windows machine is to use a rails installer. This will give you a few more files than you need, but should work on most windows machines.

###Release 0: Install Sublime Text

  • Download Sublime Text 2 You don't have to purchase your license right away (you can "cancel" out of the dialog box as many times as you would like). You'll use Sublime to edit code, similar to the way you might use Word to edit a written document. ###Release 1: Download and Run RailsInstaller
  • Download RailsInstaller (download the Ruby 2.2 version). This will install several programs that let you save and run Ruby code. Pay attention to where you install the programs (likely C: or C:\Program Files), as you may need to navigate there later if you can't find your RailsInstaller programs.

Release 2: Get to Know Git Bash (aka Your Terminal, aka the Command Line)

  • Once you've downloaded and run the RailsInstaller, you should be able to find a program called Git Bash. On some versions of Windows (such as Windows 7), you will do this by clicking the Start bar and navigating to the RailsInstaller folder to find Git Bash inside of it; on other versions (such as Windows 8), you will see Git Bash listed directly among your installed programs.
  • Git Bash is your terminal, which gives you a way to communicate with your computer. When we say things like "run the following command on the command line" or "type this into your terminal," we are referring to this window. Whenever we give you multiple commands (one on each line), run them in order, separately, hitting Enter in between each one.

Release 3: Enable the subl Command

  • Throughout the course, you'll see us telling you to run commands like subl somefile.html, which is a handy way to open files in Sublime from the command line. That doesn't work in Windows without some extra setup on your part.

  • This is optional, though -- if you'd rather, you can always simply drag files into Sublime to open them, or navigate to the files you'd like to open using Sublime's File > Open File ... and File > Open Folder ... menu

  • To activate the subl command, in your Terminal, run

cd C:

and then

ls
  • In response, your terminal should show you a listing of all the files and folders on your hard drive. We're looking for RailsInstaller in this list. You might see it there. If you don't see it (and only if you don't see it), run

cd Program\ Files
ls

and then check again. (We're basically peeking around in your files to find where RailsInstaller lives.)

At any rate, once you see RailsInstaller in the list, run

cd RailsInstaller/Git/bin
touch subl
notepad subl

This will open a blank text file in Notepad. (If that last command didn't work, you can also open Notepad directly, go to File > Open, and navigate to the subl file we just created.)

Copy and paste the following content into the file (including the blank line at the bottom), save, and close the file.

#!/bin/sh
"C:\Program Files\Sublime Text 2\sublime_text.exe" $1 &

Close your& terminal, then restart it.

Give it a try -- does this work? (It might take a second to load.)

subl test.txt

This should create a blank text file and open it in Sublime that you can edit. If you close without saving any changes, you won't have to clean up after yourself. If the above command worked, you can also open a directory in Sublime with

subl .

If you got an error instead, don't stress -- this isn't required, and we can help you get it working if you decide you want to spend more time on it.

###Release 4 - Install Sinatra Gem

  • If the steps above have successfully installed Ruby, you should be able to install gems. Type gem install sinatra. If you don't get any errors, you are good to go!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment