Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save D4v1X/2d28092090e8a4443abd to your computer and use it in GitHub Desktop.
Save D4v1X/2d28092090e8a4443abd to your computer and use it in GitHub Desktop.
Installing Ruby and Rails using RVM, Homebrew and more on Mountain Yosemite 10.10

#1. Install Xcode

In order to compile Ruby with RVM, as well as many Homebrew packages, you'll need a compilation toolchain. If you are doing Mac or iOS development, you may want to install Xcode in its entirety.

The first command we will run will serve to verify that Xcode successfully installed GCC:

gcc --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0

#2. Install Homebrew

Homebrew is my preferred way of managing packages in OS X. Homebrew compiles most packages from source and keeps everything nicely managed within /usr/local. It can be installed by running:

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

Once the installation is successful, run the following command:

brew doctor
Your system is ready to brew.

Warnings:

#3. Install Ruby and Rails using RVM

Note: the following commands should be run as a non-root user (i.e. no sudo).

To install the latest stable version of RVM, run the following from a terminal window:

$ \curl -sSL https://get.rvm.io | bash -s stable

Close and reopen the terminal window.

rvm -v
rvm 1.26.4 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Then install the latest Ruby version with:

$ rvm install ruby

You can confirm this has installed correctly by running:

$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]

Ruby is now installed, go ahead in type irb in the terminal, and play around with Ruby.

irb
2.1.5 :001 > 2+1
 => 3 
2.1.5 :002 > exit

Then we can install and verify Rails with the following commands:

$ gem install rails
$ rails -v
Rails 4.1.8

#4. Install Git

Git is the version control system of choice among many web developers. With Homebrew, installing Git is as easy as this:

brew install git

Once the installation is successful, run the following command:

brew doctor

Check that Git is installed:

$ git version
git version 1.9.3 (Apple Git-50)

Configure Git if you haven’t used it before. First, list the current settings with the git config -l --global command. Then set user.name and user.email if necessary:

$ git config -l --global
fatal: unable to read config file '/Users/.../.gitconfig': No such file or directory
$ git config --global user.name "Your Real Name"
$ git config --global user.email me@example.com
$ git config -l --global
user.name=Your Real Name
user.email=me@example.com

#5. Connect with Github [SSH] Generate a new SSH key

$ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

Then add your new key to the ssh-agent:

# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 29251
ssh-add ~/.ssh/id_rsa

Add your SSH key to your Github account:

$pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

in Github account go to settings -> SSH keys -> Add SSH key -> [PASTE] -> Add key.

Test everything out:

$ssh -T git@github.com
# Attempts to ssh to GitHub

The authenticity of host 'github.com (207.97.227.239)' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)? yes

Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment