Uninitialized Constant Gem::GemRunner Error
Recently, I was attempting to freeze a Rails app at work. When I attempted to run rake rails:freeze:gems
, I received this fun error:
uninitialized constant Gem::GemRunner
I had heard some rumor of an issue with Gem version 1.0.x and Rails versions less than 2.0. I was hoping that some magical silicon gnome would smooth out the wrinkles before I got a chance to trip over one, but alas, that was not the case.
Apparently, since Gem version 0.9.5, gem_runner is not required automatically for the rake tasks. The simple solution is to edit your framework.rake file, and add the require line in the rails:freeze:gems task. (For me, located in ‘/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks’.) It should end up looking something like this:
namespace :rails do
namespace :freeze do
desc "Lock this application to the current gems (by unpacking them into vendor/rails)"
task :gems do
deps = %w(actionpack activerecord actionmailer activesupport activeresource)
require 'rubygems'
require 'rubygems/gem\_runner'
Gem.manage\_gems
I hope that helps someone.