It seems like I am, entirely too frequently, setting up a new development environment for Ruby on Rails. Between the computers at work and at home I feel like I am starting over, from scratch, somewhere every 6 months or less. Whenever I make a substantial change to my development environment, I like to document it here for my own reference and in the hopes that it may help others.
This go around I am incorporating some recent additions to the stack, notably Homebrew and rbenv. These additions, as well as a few other changes are being made to simplify things and to follow the latest best practices.
The steps I followed to setup my development environment are as follows:
1. Install Homebrew – the missing package manager for OSX. Luckily I didn’t run into any issues installing Homebrew. Homebrew greatly simplifies installing some of the more difficult bits and pieces on OSX.
2. Install rbenv – This differs from my previous use of RVM. While I really liked RVM, the simplicity of rbenv convinced me to switch. Again, no real issues with installation (that is the beauty of a single purpose, simple tool). I didn’t use Homebrew to install rbenv, but in the future I will. With rbenv I also installed the companion ruby-build which simplifies the process of installing various Ruby versions.
3. Install PostgreSQL – While I am a longtime fan of MySQL, it’s acquisition by Oracle combined with the herd moving towards Postgres made me take the plunge. All in all it has been a fairly straightforward process. There is one caveat, when installing Postgres on OSX Lion (which replaced it’s bundled install of MySQL with Postgres) you need to make a minor change to the system paths so that Postgres loads from your installation and not the built in one. I followed the tips from a few blogs and updated /etc/paths, placing “/usr/local/bin” at the top. That one tip, combined with following the instructions provided by Homebrew (accessible via “brew info postgresql”) will get Postgres up an running in no time.
That is basically it! I think this is a really clean and simple install that makes my apps fairly portable. I am using Bundler to manage my Ruby Gems in conjunction with the rbenv-gemset plugin. I could just rely on Bundler, but I prefer to have the gems sandboxed in a separate gemset (for now).
After cloning from GitHub and running “bundle install” and the various rake database tasks I was up and running in development mode with relative ease. One of the wonders of the open source software community is that there seems to be a real emphasis on continuous and meaningful improvement. With each major iteration the tools I am using are becoming both more powerful and easier to use. I was able to get my development environment up and running in about an hour (less if my memory were better). That pales in comparison to some of the herculean efforts required in the past.