Setting up your development environment from scratch
It’s my first week at Turing, hooray! We had to set up our machines to
get them ready for working in a development environment. I’ve only done this
a few times before now and I thought I should document it so moving
forward I have a reference and anyone else who may be coming after me
could have a resource!
Software Updates
First, we want to check for any software updates, because even though
it’s a new computer, there’s almost always an update. Super fun.
- Check for any OS software updates on App Store
Update sudoers file
There are a some installations that will stop part way through for a
sudo, and I find it obnoxious, so I usually change this off the bat.
1 | sudo visudo |
Sudo allows you to run commands as a user with higher access rights, which is why it prompts you for your password
Once in file, change1
%admin ALL=(ALL) ALL
to1
%admin ALL=(ALL) NOPASSWD: ALL
Xcode Install
Next up, our favorite thing, XCode! You can get by with just the command
line tools, but there are some instances where you may need the whole
thing EDIT(updated below when I started using MacVim).
1 | xcode-select --install |
Install homebrew
If you don’t know what homebrew is, I highly highly recommend using it.
Basically it allows you to install and update software via this magical
package manager rather than grab the URLs each time. You can read more about
HomeBrew here: [http://brew.sh]
- run command
1 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
Once the installation is successful, run the following command:
1 | brew doctor |
If you get “Your system is ready to brew”, you can move on to installing rvm and ruby.
Otherwise, try a few of these troubleshooting tips:
Most cases, Homebrew will provide helpful instructions for with warnings and errors and you can follow those step by step. Here are a few common ones:
- If you get:
1 | Warning: /usr/bin occurs before /usr/local/bin |
- run command
1 | echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile |
This command takes everything between the single quotes and adds it (>>) to a file called .bash_profile in your user’s root directory (~/). Every time you open a new Terminal window or tab, .bash_profile is called. The export PATH line tells your system to look in /usr/local/bin first, since that’s where Homebrew installs tools.
- If you get:
1 | No such file or directory - /usr/local/Cellar |
- run command
1 | mkdir /usr/local/Cellar |
This creates the /usr/local/Cellar directory
mkdir stands for “make directory”, which you’ll use when creating
folders from your command line (no gui!).
- If you get:
1 | /usr/local/etc isn't writable |
or1
Cannot write to /usr/local/Cellar
- run command
1 | sudo chown -R `whoami` /usr/local |
This makes you the owner of the /usr/local directory, in addition to all nested directories.
chown stands for “change owner”, the -R flag applies this to all nested files and directories, and whoami is a variable that represents your OS X username. You should copy and paste the command above as is.
To learn more about any Unix command, type man (for “manual”), followed by the command.
For example:
1 | man chown |
If a manual is longer than a page long, it will display a : at the end to signify there is more to read. To display one additional line at a time, press return. To display an additional page at a time, press the space bar. To quit at any time, press q.
Hopefully you’ve had no trouble, and you’re ready to move on!
Install rvm and ruby
Next up, RVM and Ruby! RVM stands for Ruby Version Manager . This is my preference as I’ve been using it for a few years, but there is also a
[rbenv] (http://rbenv.org) and they essentially do the same thing, so it’s a user preference. Both of these are used to manage different versions of Ruby, so you can have projects using 1.9.3 or 2.0.0.
- run command
1 | \curl -sSL https://get.rvm.io | bash -s stable |
- close terminal windows and reopen
- run command for ruby
1 | rvm install 2.2.2 |
Note, I’ve updated this to use the latest version of ruby, so be sure
to check which one is the most stable before installing.
Check to see you’ve installed the correct version
- run command
1 | ruby -v |
This should give you the version number of ruby for whichever directory you are in.
Install git
Wooo, Git! The best thing, really. Git, simply put, is a version control
system and you’ll use it ALL the time and probably never fully
understand it.
- run command
1
brew install git
Install mysql && postgres
I like to have both of these pending on the projects, I usually only
have postgres for cases of deploying to Heroku.
- run command(s) Mysql
1 | brew install mysql |
- run command(s) Postgres
1 | brew install postgresql |
- Helpful gem for starting and stopping a server on postgres
1 | gem install lunchy |
Note, these versions will be specific to your machine, this is my version of Postgres that was installed on my machine. If the version number has changed since I’ve written this, using the command below won’t work for you, so you should make sure to copy the command from your Terminal output.
1 | mkdir -p ~/Library/LaunchAgents |
Now you can start and stop postgres simply with these commands:
1 | lunchy start postgres |
and1
lunchy stop postgres
Install vim
You’ll need this for editing commit messages and working with servers,
good to have even if it’s not your preferred editor.
1 | brew install vim |
EDIT: Using MacVim months later and had to install all of Xcode
##Install MacVim
- install Xcode
1
brew install macvim
I like to use the theme ‘jellybeans’, but you can choose whichever is
easiest. MacVim was a nice ease into vim from my Sublime and Atom
editor.
EDIT: Now using Tmux for work and it’s amazing for having everything in
one place.
##Install tmux
- run command
1 | brew install tmux |
##Setup tmuxinator
- run command
1 | gem install tmuxinator |
- see what $EDITOR is set to
1 | echo $EDITOR |
- if not set, set it
1 | export EDITOR='vim' #add to bash_profile to make permanent |
- open your ‘project’ and set it up
1 | mux open project_name |
configure windows, panes, etc.
to start working
1 | mux project_name |
Install Seil to map Caps Lock to Esc
Install janus for VIM Rails editing
1 | curl -Lo- https://bit.ly/janus-bootstrap | bash |
Install Ack for code searching
1 | brew install ack |
And that’s about it! You should be all set to go on your environment to
start coding plus some. Hope this helped, enjoy!