OS X
Please upgrade to the latest version of OS X, Yosemite, and download & install an application called XCode through the App Store.
Windows
You will need to set up your computer to dual-boot to Linux Ubuntu before you can get started - if you need help with this, please contact an instructor.
Linux Ubuntu
Nothing! You're all set!
Those of you who are on Ubuntu already have a powerful package manager, apt
, built into your operating system. However, OS X doesn't come with a package manager installed, so we'll be installing a 3rd-party package manager called Homebrew to install software from the command line. If you're running Linux, please feel free to skip ahead to the next section, 'Node/NPM and JShint'
In order for Homebrew to work, we'll need to rely on a number of programs that come pre-installed on Linux. You can install these tools either:
-
via the terminal using the command
xcode-select --install
. This may require that you run a Software Update before proceeding.NOTE: This option is only available with Xcode 5.1 and OS X Mavericks (10.9) or higher. For earlier versions, it may be possible to download Command Line Tools from within Xcode - consult with an instructor before moving forward.
-
from the Apple Developer Tools site, if you sign in with a developer account. Be sure to get the Yosemite version!
- First, go to http://mxcl.github.io/homebrew/, scroll down to "Installation" and copy and paste the entire command listed there into your terminal.
- Next, in order to run Homebrew from the command line, you must ensure that the homebrew directories are included in your PATH environmental variable by running the following two commands.
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
You will also need to update /etc/paths
by running the following command.
echo '/\/usr\/local\/bin/\nd\nwq' | sudo ed /etc/paths
echo '1i\n/usr/local/bin\n.\nwq' | sudo ed /etc/paths
- Homebrew has a built-in diagnostic tool to determine if it's working correctly; you can run it by entering the command
brew doctor
into your terminal.
NOTE: YOUR SYSTEM WILL PROBABLY THROW SOME ERRORS HERE! Some of these errors are probably minor, but some might not be; please wait until one of the instructors has given you the go-ahead before moving on.
- Once Homebrew says
Your system is ready to brew
, runbrew update
to update Homebrew's directory of packages.
We're going to be installing Node next; Node (and its various packages) will be the foundation of a large part of the course. First, though, we're going to download a tool called NVM that allows us to maintain multiple different versions of Node, in case we want to switch between them for different projects. Then we'll download Node, and use its associated package manager, NPM, to download and install the following Node modules:
- JShint, a tool for testing JavaScript code quality. (
jshint
) - Grunt, a tool for automating background tasks. (
grunt-cli
) - Bower, a tool for managing front-end assets and libraries, such as jQuery. (
bower
) - Yeoman, a scaffolding tool to make building projects easier. (
yo
)
- Run one of the following commands to install NVM.
brew install nvm
sudo apt-get install npm
- Add the following snippets to your bash configuration files (
.bash_profile
on OS X,.bashrc
on Linux).
# NVM
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
# NVM
export NVM_DIR="/home/your_username/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads NVM.
- Use NVM to install the latest stable version of Node
nvm install stable
- Finally, use NPM to install the Node modules mentioned earlier and make them available across all of our projects.
npm install -g jshint grunt-cli bower yo
#Sublime Text 3
- Download the latest Sublime Text build from http://www.sublimetext.com/3.
- Double-click the .dmg file to open it, and drag the icon into your 'Applications' folder.
- Next, enter the following into your terminal - it will create a 'symlink', a shortcut that we can use to open Sublime from the command line.
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
-
Add the PPA (personal package archive) for SublimeText 3 to
apt
and update your package directory.sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
-
Use
apt
to install SublimeText 3sudo apt-get install sublime-text-installer
-
Create a symlink shortcut for your terminal.
sudo ln -s /**wherever the binary for Sublime is** /bin/subl
Once Sublime Text is installed, there are a couple of modifications that you'll need to make before you're all set.
####Set Preferences
Go to your Preferences in Sublime Text, open "Settings - User", and replace the entire contents with the following:
{
"autocomplete_on_tab": false,
"ensure_newline_at_eof_on_save": true,
"ignored_packages":
[
"Vintage"
],
"scroll_past_end": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true
}
Note: If you've already made other customizations to this preferences file, you'll need to manually add them back later.
Don't forget to save the file before closing it!
####Install the Package Manager
One of Sublime Text's best features is its extensibility - there are a wide variety of add-ons and extras. To keep all those add-ons organized and up-to-date, we'll need a package manager.
Hit ctrl + `
to enter the Sublime Text console; there, paste in the following code.
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())
####Install Add-On Packages
- Hit
command + shift + p
to enter the Command Pallette; and enterinstall
into the search bar to open the package manager in 'advanced' mode. - Install each of the following plugins:
All Autocomplete, AngularJS, BeautifyRuby, Better CoffeeScript, Dotfiles Syntax Highlighting, GitGutter, Haml, Handlebars, HTML5, jQuery, Sass, SideBarEnhancements
##GitHub
If you haven't done so already, go to www.github.com and create and account; be sure to write down your username and password somewhere, since we'll be using these credentials later.
##Installing Git
For OS X, enter the command brew install git
. For Linux, enter sudo apt-get install git
. Easy as pie!
##Configuring Git
Now let's take care of some settings.
-
Show the current Git branch in the terminal prompt
Run the command
subl ~/.bash_profile
to open up .bash_profile, a hidden settings file for the terminal. Paste the following code into the bottom of the file.# Git function parse_git_branch { ref=$(git symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" } export PS1="\w \$(parse_git_branch)\$ "
Follow the instructions given for OS X, but replace
.bash_profile
with.bashrc
-
Tweak Git's EDITOR variable so that commit message pop-ups open in Sublime.
echo "export EDITOR='subl -w'" >> ~/.bash_profile
-
Colorize git in the command line
git config --global color.ui true
-
Set up a global 'excludesfile', listing all the files that we might want git to ignore.
git config --global core.excludesfile ~/.gitignore
echo ".DS_Store" >> ~/.gitignore
-
Set a default user
git config --global user.name "yourUsername"
git config --global user.email "[email protected]"
##Linking with GitHub
In order to push commits to GitHub from the command line, we need Git and GitHub to have a matching set of SSH keys.
- Generate a new key by running
ssh-keygen -t rsa -C "[email protected]"
(feel free to put in a password or select a non-default location for your keys, but it's not necessary to do so; to move ahead, just keep hittingenter
). - Add this new key to your system by running
ssh-add ~/.ssh/id_rsa
- Copy the new key to your clipboard using either
pbcopy < ~/.ssh/id_rsa.pub
(OS X) orxclip -selection clipboard < ~/.ssh/id_rsa.pub
(Linux); then, log into GitHub.com, go to https://github.com/settings/ssh, and paste in your SSH key. To test it out, type the following into the command line:
ssh -T [email protected]
If you get a prompt along the lines of
The authenticity of host 'github.com (xxx.xxx.xxx.xxx)'... can't be established.
RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX.
Are you sure you want to continue connecting (yes/no)?
just type 'yes'. If everything's working, you should get a response like the following:
Hi yourUsername! You've succesfully authenticated, but GitHub does not provide shell access.
##From Rbenv to Ruby
Rbenv is a tool that we can use to manage multiple versions of Ruby and determine which version we use for a particular project.
- Install Rbenv
#####OS X
Run `brew install rbenv`.
#####Linux
Copy and paste this entire line into your terminal and run it.
`curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash`
- Tell Rbenv to use homebrew's directories instead of rbenv's
#####OS X Open ~/.bash_profile and paste in the following code BEFORE the stuff you pasted in about Git.
```bash
# Rbenv
export RBENV_ROOT=/usr/local/var/rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
```
#####Linux
Open ~/.bashrc and paste in the following code BEFORE the stuff you pasted in about Git.
```bash
# Rbenv
export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
```
Once you've done this, run source ~/.bash_profile
(or .bashrc
on Linux) to reload the terminal's settings.
-
(OS X only) Install a tool to re-hash gems after each installation (Linux users, unfortunately must do this manually).
brew install rbenv-gem-rehash
Then download a package with a number of common gems.
`brew install rbenv-default-gems`
-
(Linux only) Rbenv on Linux depends on another library called
libffi-dev
. Download and install it with the following command.sudo apt-get install libffi-dev
-
Install
ruby-build
, a plugin for rbenv.
#####OS X
`brew install ruby-build`
#####Linux
`git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build`
`rbenv install ruby-build`
- Install version 2.2.0 of Ruby and make it the system-wide default using the command
rbenv install 2.2.0 && rbenv global 2.2.0
You can see what versions of Ruby rbenv has downloaded by running rbenv versions
; to see which version you are currently using, type either rbenv version
or ruby -v
.
Now that you have Ruby installed, you can begin to install gems on your own. However, gems usually come with a lot of unnecessary documentation - let's tell Ruby to skip those by running the following command:
echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
Next, we'll go ahead and install Rails.
gem install rails
Here are a couple of other gems we should also install.
gem install bundler
#Postgres
Next, we'll download Postgres, the database program we'll be using for most of the course.
- First, download and install Postgres.
#####OS X
Download and install the Postgress App : http://postgresapp.com/
#####Linux
Run sudo apt-get install postgresql libpq-dev
to install Postgres and its dependencies.
- Once you've installed Postgres, install the postgres gem from the command line so that Ruby can access it.
#####OS X
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
#####Linux
gem install pg
Linux folks must also specify a default database user, using the following command:
sudo -u postgres createuser *<ubuntu_username>* -s
See https://help.ubuntu.com/community/PostgreSQL if you run into any issues with the installation.
- It's terminal shortcut time! Let's configure a
psql
shortcut so that we can run Postgres from the command line.
#####OS X
Create a new terminal shortcut, just like we did with Sublime Text.
ln -s /Applications/Postgres.app/Contents/Versions/9.4/bin/psql /usr/local/bin/psql
#####Linux
Linux already has a shortcut set up for us; just add the existing shortcut to the environmental PATH variable.
echo "export PATH=/usr/local/psql/bin:$PATH" >> ~/.bashrc
#CONGRATULATIONS! YOU'RE READY TO ROLL!
rbenv install ruby-build
is unnecessary; the git clone intorbenv
's plugin directory completed the install.gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
isn't going to work on Linux. Installed just fine truncated togem install pg
for me.Point 4 under Postgres:
echo "export PATH=/usr/local/psql/bin:$PATH" >> ~/.bash_profile
should be
echo "export PATH=/usr/local/psql/bin:$PATH" >> ~/.bashrc