Mac Development Setup for Hobbits

Ruby

Before installing Ruby, we will install rbenv.

rbenv manages the Ruby versions for your applications and guarantee that your development environment matches production. I know that rvm is a more popular pick on this subject, but this rundown summarizes the good reasons to pick rbenv instead.

To install run:

$ brew install rbenv ruby-build rbenv-gem-rehash

For other usefull plugins checkout this list. Here is my list:

  • rbenv-vars: lets you set global and project-specific environment variables before spawning Ruby processes.
  • rbenv-default-gems: creates a hook into the rbenv install command to automatically install gems every time you install a new version of Ruby.

There is a known bug with Mac OSX default openssl. Due to that, we have to install Hombrew's openssl package.

# uninstall it first if you already have it
$ brew uninstall openssl

$ brew install openssl

After that, add the following line to your ~/.zshrc.

# To use Homebrew's directories rather than ~/.rbenv add to your profile:
export RBENV_ROOT=/usr/local/var/rbenv

# To enable shims and autocompletion add to your profile:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

# To fix the openssl but with Homebrew package
export CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`"

Warning: Make sure you add the following lines after the PATH definition.

Now, for each local environment, you have to set it (and install it if needed):

$ rbenv install 2.2.2
$ rbenv local 2.2.2

Then you can set your favorite Ruby version:

$ rbenv global 2.2.2

Gems

First lets avoid gems to install documentation, we don't need that, we have the interwebs. Add this couple of lines to you ~/.gemrc file:

install: --no-rdoc --no-ri
update: --no-rdoc --no-ri

The rbenv-default-gems plugin will automatically installs the gems listed in the ~/.rbenv/default-gems, every time you successfully install a new version of Ruby with rbenv install. Here is my default-gems file:

bundler

</br>

Don't touch my rubies ...