andhapp Random ramblings

Bundler and Rails 2.3.8

Life as a “Rails Developer” is a pretty smooth sailing and Bundler just makes it ever better. Rails 2.3.8 is the newest version from the Rails team. Don’t get me wrong, I love to hack my way through Rails3 but time is a big constraint for the project I am working on at the moment. With Rails3, I am bound to hit some road blocks but this is just a quick project I would like to get done and over with.

I am not going to talk about how to initialise bunder and create a Gemfile. You can follow that easily from the github page. So, for the sake of this post let us assume that this is what your Gemfile looks like:

source :gemcutter

gem "rails",          "2.3.8"
gem "i18n"
gem "formtastic",     "0.9.1"

group :test do
  gem "rspec",        "1.3.0"
  gem "rspec-rails",  "1.3.2"
end

Now, when you run the following command:

bundler install vendor

you will get an error related to ruby_version_check.rb not found or something similar complaining about the absence of ruby_version_check ruby script. To fix it, just create a file named ruby_version_check.rb in your project’s lib folder and copy the contents of this gist in it. I copied this file from the Rails master branch and changed the min_release variable to 1.8.6 since 1.8.7 gave me some nasty segmentation errors on my mac. But if you have 1.8.7 installed and working correctly, change the min_release back to 1.8.7.

Next, step is to add the following code to your environment.rb file:

require "bundler"
Bundler.setup

and you should be good to go.

However, there are two things that I have not yet figured out a solution to:

  1. Using Rails engines like clearance since the generators have been completely revamped in Rails3 and might need a through investigation. So, for now I have added it in the old way using config.gem syntax in the environment.rb file.
  2. I got some strange error on time zone which went away by commenting out config.time_zone = ‘UTC’ line of code. This still needs investigation.

I hope this helps anyone trying to get their head around using Bundler with Rails 2.3.8. This set up might work with pervious versions and if you will try it out for yourself.

Update: Just tried using rspec_controller generator and it can’t be invoked as well. So, using Bundler does not hook up the generators. Although. I would think that should not be the case since Bundler adds all the required libs to the $LOAD_PATH so that they are found when Rails goes looking for them. Needs more investigation.