-
Notifications
You must be signed in to change notification settings - Fork 5
Development Environment Setup: Mac OS X
This document explains how to get your computer ready for development at Startup Institute. Code or commands you’re supposed to type are highlighted
. Ex: $ ls -la
Note: It is strongly recommended that you type out the commands instead of copy-paste them (unless where noted). You will remember much better than if you copy and paste from this document.
Click here to download XCode
Xcode is Apple’s development environment. You need it installed before you can install anything else. It comes with tools used to compile programs from source. These are code compilation tools that you can access from the command line. Apple currently uses a compiler called LLVM. Another (very) popular compiler is GCC. There are a few programs that may require GCC instead of LLVM.
- Open up XCode from your applications folder
- Go to the toolbar: Click Preferences → Downloads → Check install command line tools
- OS X Mountain Lion: Issues with GCC / XCode (link)
The “Terminal” is a program that comes with all macs. Open Spotlight (⌘+Space) then type “terminal”. (You’re also welcome to use a popular alternative called iTerm (why would I?)). Regardless of what you use, open it up and get ready to use it.
The terminal is a powerful interface to use your computer. Since the computer terminal was invented before the mouse, everything you do must be done by typing commands then hitting ‘enter’.
The “commands” you can use in the terminal is based off of a set of conventions that were created with the Unix operating system (the same OS that Mac is built on top of).
It is useful to learn the most common Unix commands. There are about a hundred total, but only a dozen everyone uses every day. A basic tutorial can be found here.
The first thing we will use the terminal for is to install a program called Homebrew. This is a utility that makes it very easy to robustly install the other programs we will need in the immediate future. You will install Homebrew by cut and pasting a single line into your terminal. From the Homebrew homepage, we see that it is just a simple command to install (copy-paste this):
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/Homebrew/go)”`
Homebrew is a program used to install other programs with great ease. The line above will use ruby to grab and execute an installation script at the raw.github.url that they have. That installation script will install Homebrew onto your system.
Insert the Homebrew directory at the top of your PATH environment variable by typing into your terminal the following two commands:
$ echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile<ENTER>
$ source ~/.bash_profile<ENTER>
Your “PATH” is a list of directories on your computer. When you execute a command, “terminal” will attempt to find the location of that command by traversing down this list from beginning to end. Thus, the order of those folders matter. For example, if you type git, “terminal” will look through the list of folders until it finds that command, and then execute it.
When you install a program using Homebrew, it puts that program at /usr/local/bin. The first line above “echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile”
tells your computer to prepend the /usr/local/bin folder before the rest of your PATH. This causes the program version that Homebrew installs to execute before any others (with the same name), that might have been installed earlier.
The second line applies and refreshes those changes.
$ brew doctor<ENTER>
Follow the instructions until it says “your system raring to brew”
Homebrew comes with a sweet utility that checks your system to make sure everything is set up properly. If you have a new system, you shouldn’t have much trouble. If you’ve been tinkering in the past, there may be a couple things that need to be updated.
Basically it ensures that /usr/local/bin is clean and under the control of Homebrew. It also makes sure you have the correct compilers, and there are no conflicting programs installed on your system. Most issues can be fixed by trying to type the commands they suggest.
Go to github.com and make an account. Keep your username and email professional; if you have a handle that you use other places, use it here too. If you don’t, it’s a good idea to use some combination of your first name and last name. GitHub is an extremely popular company that makes it very easy to host git repositories (ie, this is where you put your code so that many people can work on it together). “git” is a VCS (Version Control System).
Almost all major open source projects are hosted on Github, which makes it an important tool for your toolbelt. Because so many developers use Github, your public Github profile is often viewed as a professional portfolio. It’s a good way for employers and community members to see what projects you’ve contributed to, what you’re interested in, and your skill level. It’s often the first place employers will look when beginning the interview process, and it can serve as a résumé replacement.
Use brew to install git
$ brew install git
This is where you use Homebrew, the installation tool you setup earlier. In this one line, you will automatically download the program (git) from the internet, compile it, and install it.
Understanding version control, and using it well is a very valuable skill. You’re Git knowledge will affect your ability to a" collaboratively create web applications, b) communicate with your team, b) track the history of your work, c) and revert mistakes. Git is a challenging tool, but worth the battle. A great way to start is “Understanding Git Conceptually”.
Follow these instructions.
Now we’ll set up SSH keys for GitHub. Go here and follow those instructions.
Before you can use GitHub, you must first enter in your basic credentials, and then setup a way to securely communicate with their servers.
SSH (Secure Shell) is a network protocol for secure data communication. You’ll hear people say “I shelled into that server.” What they mean is, “I used the SSH protocol to securly connect with a remote computer so that I could run commands on it.” We won’t get into SSH much during this course, but it’s good to understand the basics.
Follow the instructions here: https://devcenter.heroku.com/articles/quickstart
Step 14: Download the Sublime 2 install for Mac from here
Sublime is the recommended text editor. You don’t have to use Sublime. If you have another editor you like, you can stick with that. Sublime provides a lot of cool community plugins that can make you more efficient as a coder.
$ ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
This allows you to run sublime from the command line by running subl.
From the RVM install page, we get this command:
$ \curl -L https://get.rvm.io | bash
Check that it worked:
which ruby
That should show you something with /.rvm
in the path, like this:
/Users/chaz/.rvm/rubies/ruby-1.9.3-p143/bin/ruby
If you see that, then run this:
rvm rubygems latest
If you don't see /.rvm
when you run which ruby
, try this:
$ echo [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
$ source ~/.bash_profile
If you see ruby-1.9.3 when you run which ruby
, then you're good to go. If not, then run these commands.
$ rvm install 1.9.3
$ rvm use 1.9.3
$ rvm --default 1.9.3
rvm rubygems latest
"Installing Rails from the RailsApp project": http://railsapps.github.io/installing-rails.html
"How to Install Xcode, Homebrew, Git, RVM, Ruby & Rails on Snow Leopard, Lion, and Mountain Lion": http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/