OS X Mavericks may ship with Ruby 2.0. Cool, right? Don’t touch it.
The root problem is not with using a pre-installed Ruby per se, but with not using a Ruby version manager.
PC users will remember DLL hell. Ruby developers have dealt with similar problems.
Problems regarding gem dependencies are introduced after upgrading
sudo-installed gems. At this point you are left to shepherd the gems and dependencies of Rubygems on your system’s install. Plain vanilla dependency management of Rubygems is not for the faint of heart, this is why Bundler exists. It could be argued that Bundler singlehandedly saved the Ruby ecosystem from this issue. If you don’t plan to use Bundler to manage your Ruby-based app dependencies you will shoot yourself in the foot.
For your Ruby-centric applications use Bundler.
If you’ve run into issues with Ruby and decided to upgrade your system’s runtime you stand the chance of breaking tools that may depend on your old install. Tools like VIM depend on what it was compiled against. Making that update could very well impact the tools that have been built against it.
Ruby “version managers” will install Ruby and configure your environment for their use.
- rbenv is a light-weight solution from 37Signals that we default to in our laptop setup.
- Chruby and ruby-install (installation instructions) are the latest option and leave the lightest footprint of the three. Pat Brisbin, a thoughtbot teammate, has a recent blog post about chruby that is worth reading.
- RVM (installation instructions), the father of Ruby version managers. Full disclosure - I am a happy user and supporter.
The amount of uncertainty is too great to build your working environment around the default Ruby-related tools. For the experienced Ruby developer this is nothing new. For the beginner or novice working with Ruby for the first time this might not be quite so obvious. Consider how many gems still recommend using
sudo gem install in their instructions? If your project is one of them, please update it to not do so.
Special thanks to Pat, Gabe, Joël and Dan for contributing to this post.