Bundler for Rails 2.3.x

Updated . Posted . Visible to the public.

Update RubyGems and Passenger

Bundler requires Rubygems >= 1.3.6. Run gem update --system if you have an older version.
It also is not compatible with older versions of passenger, so bring that up to date as well (2.2.15 works).

If you installed RubyGems through apt (which you should never do!), you may see a message giving you a hint to use apt to update.
Some people advise to install the 'rubygems-update-1.3.7' gem on Ubuntu systems if you used apt to install RubyGems.
I did that - and lost all local gems, so back up using gem list > ~/gem_list_backup before you do anything.

You can also download and install RubyGems yourself.

Install Bundler

sudo gem install bundler

Put bundler on a Rails 2.3 project

  1. Follow the instructions on bundler.io Show archive.org snapshot

    • You should have patched your boot.rb
    • You should have added the preinitializer.rb
    • You should now have a Gemfile in your project root like the one attached
  2. Remove all old config.gem ... lines in environment.rb and environments/*.rb

  3. Run bundle install. This reads Gemfile and builds Gemfile.lock with all dependencies etc.

    • If you see "Missing the Rails 2.3.8 gem." you forgot to bundle Rails.
    • If you see "Missing the mysql gem", bundle that as well.
  4. Add both Gemfile as well as Gemfile.lock to the repository.

  5. Use bundle to execute your tests using the current bundled environment. Make sure you didn't break anything:

     bundle exec spec spec/
     bundle exec cucumber -f progress
    
  6. Remove all config.gem directives from your environments.

  7. Copy Gemfile and Gemfile.lock to the production machine and run bundle install.

  8. Deploy.

Update your scripts

Most of us have some alias scripts to run all tests (e.g. ~/bin/tests). Update those scripts so they use bundle exec like this:

#!/bin/sh
bundle exec cucumber -f progress && bundle exec spec spec/

As an alternative (if you are working on both projects with and without Bundler) you might want to look into this helper script.

You don't need to change stuff that calls rake because rake is already Bundler-aware.

Bundler replaces the Cucumber version hack

We formerly used a hack Show archive.org snapshot to define a cucumber version in the past. We do not need this anymore. Therefore, open

lib/tasks/cucumber.rake
script/cucumber

and remove gem 'cucumber', '=0.4.0' if Gem.available?('cucumber')

Keep in mind that you might have to declare the version of cucumber used in the project

gem "cucumber", "0.4.0"

This article maybe help you to solve...

I18n::MissingInterpolationArgument in 'Invoice parse_functions should parse "in_days"'
missing interpolation argument in "%{count}.%m.%Y" ({:object=>Thu, 16 Sep 2010} given)

And: Don't drink & bundle!

Thomas Eisenbarth
Last edit
Tobias Kraze
Attachments
License
Source code in this card is licensed under the MIT License.
Posted by Thomas Eisenbarth to makandra dev (2010-09-07 09:09)