On my Mac I’ve recently switched from using rvm to rbenv. Since ruby is a prerequisite for many of the topics I plan on discussing here, I’ll give you an overview of how to get it going. I use the excellent homebrew package manager to get all those excellent ports installed. If you’re not using it already, I highly recommend it. Assuming you have it installed, getting rbenv going is fairly straight forward:
$ brew update
Already up-to-date.
$ brew install rbenv
==> Downloading https://github.com/sstephenson/rbenv/tarball/v0.2.1
######################################################################## 100.0%
/usr/local/Cellar/rbenv/0.2.1: 32 files, 156K, built in 2 seconds
$ brew install ruby-build
==> Downloading https://github.com/sstephenson/ruby-build/tarball/v20110928
######################################################################## 100.0%
==> ./install.sh
/usr/local/Cellar/ruby-build/20110928: 21 files, 88K, built in 2 seconds
Next we need to install a ruby. Lets install MRI 1.9.2-290:
$ rbenv install 1.9.2-p290
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /Users/zsprackett/.rbenv/versions/1.9.2-p290
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz...
Installing ruby-1.9.2-p290...
Installed ruby-1.9.2-p290 to /Users/zsprackett/.rbenv/versions/1.9.2-p290
Downloading http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz...
Installing rubygems-1.8.10...
Installed rubygems-1.8.10 to /Users/zsprackett/.rbenv/versions/1.9.2-p290
After installing a new ruby binary or any time you install a gem that provides a binary, you’ll want to run:
$ rbenv rehash
Since we’re going to use this version as our default ruby, we need to let rbenv know:
$ rbenv versions
1.9.2-p290
$ rbenv global 1.9.2-p290
$ rbenv versions
* 1.9.2-p290 (set by /Users/zsprackett/.rbenv/version)
You’ll likely want to add something like the following to your shell rc files:
eval "$(rbenv init -)"
rbenv-gemset is a plugin that lets you use gemsets or collections of gems for projects that don’t use bundler. Once installed, rbenv will search all ancestors of your working directory for a .rbenv-gemsets file. If found, commands involving gems will use those specified in the file. It is completely optional. To set it up, do the following:
$ brew install rbenv-gemset
=> Downloading https://github.com/jamis/rbenv-gemset/tarball/v0.2.1
######################################################################## 100.0%
==> Caveats
Run the following command to complete the installation of rbenv-gemset:
rbenv gemset install
==> Summary
/usr/local/Cellar/rbenv-gemset/0.2.1: 2 files, 12K, built in 2 seconds
$ rbenv gemset install
rbenv-gemset plugin installed
you call ‘==> ./install.sh’ in the step following the ruby-build download, but there’s no script “install.sh” in any of the directories below “Cellar”. What/where is this script?