Julian Yap

Setting up a Ruby rbenv environment on OS X

rbenv is the best way to set up a Ruby environment. It's pretty essential since you can test your stack against different versions of Ruby and gems such as Rails.

... It's pretty much like virtualenv for Python.

I don't always use Ruby but when I do I use rbenv (said in the Dos Equis man voice).

Install rbenv and ruby-build via brew

brew update
brew install rbenv
brew install ruby-build

Add rbenv init to your shell to enable shims and autocompletion.

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Select the version of Ruby to install. First list all the available versions

rbenv install -l

For example, let's install the latest version in the 1.9.3 branch

export VERSION=1.9.3-p392

Build and install Ruby without documentation (saves time)

CONFIGURE_OPTS="--disable-install-doc" rbenv install $VERSION

Set the global Ruby version

rbenv global $VERSION

Disable ri and rdoc documentation for Gems. Add to ~/.gemrc

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

Or:

cat << EOT > ~/.gemrc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
EOT

Bonus points. Install Rails

gem install rails
26 MARCH 2013 @ 09:52PM

Pages

Follow Me

Google+ RSS