Skip to content

Instantly share code, notes, and snippets.

@adamstac
Created February 11, 2011 18:50
Show Gist options
  • Star 41 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save adamstac/822811 to your computer and use it in GitHub Desktop.
Save adamstac/822811 to your computer and use it in GitHub Desktop.
A Rubyist’s guide to setting up a Mac OS X development environment using Homebrew, RVM, Git and Bundler

Xcode

Install Xcode

Head to the Apple Developer Center to download a copy of the latest Xcode

Homebrew

Install Homebrew

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Git

Install Git

brew install git

You will also want to setup your Git and GitHub user details

Setting user name and email globally in git

git config --global user.name "adamstac"
git config --global user.email "adam@stacoviak.com"

GitHub token config

git config --global github.user adamstac
git config --global github.token 0123456789abcdef0123456789abcdef

Git aliases

Setup common git aliases.

git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status

MySQL

Next we need to install MySQL. Yes, it's really this easy ... but this will take a while.

brew install mysql

Now to warm it up:

mysql_install_db

After you run mysql_install_db you'll see output like this ...

Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h AS-MBP15.local password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

When that's done, make sure MySQL automatically starts on login:

launchctl load -w /usr/local/Cellar/mysql/VERSION/com.mysql.mysqld.plist

RVM

Install RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Next you have to add RVM to your .bash_profile. See also for an example .bash_profile file.

# place in ~/.bash_profile as the very last line
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

To check everything went well

type rvm | head -n1

To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):

rvm install 1.8.7 # installs 1.8.7-p334
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
rvm --default 1.8.7

If you are planning to do development that requires ruby-1.9.2, you need to install 1.9.2 as well.

rvm install 1.9.2

SSH keys

Generating SSH keys (OSX)

First check to see if a ssh key directory exists.

cd ~/.ssh
ls -lash

If nothing is listed, then you can move on - or else you'll need to backup the existing key and create a new as needed.

ssh-keygen -t rsa -C "adam@stacoviak.com"

You should see something like this.

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/astacoviak/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/astacoviak/.ssh/id_rsa.
Your public key has been saved in /Users/astacoviak/.ssh/id_rsa.pub.
The key fingerprint is:
08:49:4b:84:c6:b0:2c:9e:dc:aa:b4:b2:ba:d8:0f:52 adam@stacoviak.com
The key's randomart image is:
+--[ RSA 2048]----+
|.o o+            |
|.++o o           |
|oo  +            |
|+ o  . .         |
| +A.  . S        |
| ..              |
|.o.              |
|=o+.             |
|O++..            |
+-----------------+

Bundler

Install Bundler

gem install bundler

If you're on an old version of Rubygems

sudo gem update --system

Setup your .gemrc

echo -e '---
:benchmark: false
gem: --no-ri --no-rdoc
:update_sources: true
:bulk_threshold: 1000
:verbose: true
:sources:
- http://rubygems.org
:backtrace: false' > ~/.gemrc

Aliases

You likely have a number of servers that you use. Open up ~/.ssh/config and create some aliases to those servers.

Host clientname_staging
  HostName staging.clientdomain.com
  User developer

Host clientname_production
  HostName clientdomain.com
  User developer

Sources

* Review this article and add new steps as needed: http://blog.therubymug.com/blog/2010/05/20/the-install-osx.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment