Skip to main content

Benjamin Oakes

Photo of Ben Oakes

Hi, I'm Ben Oakes and this is my geek blog. Currently, I'm a Ruby/JavaScript Developer at Liaison. Previously, I was a Developer at Continuity and Hedgeye, a Research Assistant in the Early Social Cognition Lab at Yale University and a student at the University of Iowa. I also organize, ICRuby, OpenHack Iowa City, and previously organized NewHaven.rb. I have an amazing wife named Danielle Oakes.

Filtering for the month July, 2008. Clear

Count vs length vs size in Rails

by Ben

I knew I had found a blog post about the differences at one point — I always get confused about it as well.

HTMLDiff in Ruby

by Ben

I ran into a problem using the HTMLDiff code found in i2 for doing nice diffs in Ruby. Of course, you’ll probably want to use in Rails, but if you are running Rails 2.1 (or maybe even other versions), you’ll want to use an updated version instead.

Update: It looks like this HTMLDiff code is no longer available at the provided links. I think I still have a copy somewhere, let me know if you need it by leaving a comment.

Loading environment fails with an outdated version of RubyGems

by Ben

My recent ticket for Rails 2.1 has gotten a fix that has been committed.

Update (2013-03-30): I came across this again today, and decided I should include the text I wrote back in 2008, since Lighthouse is no longer actively used.

I spent quite a bit of today trying to figure out an issue that
was only appearing on our Linux boxes, but not the Mac OS X
machines. This concerns the new gem dependencies feature (i.e.
“config.gem” in environment.rb). (More specifically, we are
unpacking into vendor/gems, but that doesn’t seem related to the

After a lot of debugging, I found out that the issue was
differing versions of the RubyGems utility (“gem” on the command
line) and is likely not related to differing operating systems. The
two Linux machines I was testing on had version 0.9.x rather than
the newer 1.1.1 of the Macs. (Mac users may also have this older
version if they have not updated, of course.) An old version of
RubyGems will cause Rails to fail at the very start because the
environment cannot be set up, but only if a “config.gem” dependency
is specified.

To reproduce:

Try running “rake test” (or almost anything else) on a Rails
project which does not use Gem Dependencies on a machine that has
RubyGems < 1.1.1 (not sure of the exact version — 0.9.4 and
0.9.2 were causing problems for us.) Verify that this works without
problems. (To check your version, use gem

Add any gem dependency, such as:

config.gem "httpclient"

You should receive an error such as the following (which is from
running rake test):

/usr/lib64/ruby/site_ruby/1.8/rubygems/version.rb:237:in `initialize': undefined method `collect' for nil:NilClass (NoMethodError)
    from /usr/lib64/ruby/site_ruby/1.8/rubygems/version.rb:29:in `new'
    from /usr/lib64/ruby/site_ruby/1.8/rubygems/version.rb:29:in `initialize'
    from /home/oakes/trunk/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:104:in `new'
    from /home/oakes/trunk/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:104:in `specification'
    from /home/oakes/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/symbol.rb:11:in `__send__'
    from /home/oakes/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/symbol.rb:11:in `to_proc'
    from /home/oakes/trunk/config/../vendor/rails/railties/lib/rails/plugin/locator.rb:81:in `map'
    from /home/oakes/trunk/config/../vendor/rails/railties/lib/rails/plugin/locator.rb:81:in `plugins'
     ... 17 levels...
    from /usr/lib64/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb:5:in `load'
    from /usr/lib64/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb:5
    from /usr/lib64/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb:5:in `each'
    from /usr/lib64/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader.rb:5

Then update RubyGems (sudo gem update --system).
Everything should run normally.

Something in Rails (possibly Rake) should check for the RubyGems
version and warn that it should be updated if it’s too old. That
is, something like this:

local_version = %x[gem --version].chomp

if REQUIRED_VERSION != local_version
  puts "You need to update the RubyGems utility to #{REQUIRED_VERSION} using the following"
  puts ""
  puts "    sudo gem update --system"