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.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I have the same problem, but when I try you solution, I get:

:~/ror # rake rails:freeze:gems
(in /root/ror)
rake aborted!
no such file to load -- /root/ror/config/../vendor/rails/railties/lib/initializer
/root/ror/Rakefile:4
(See full trace by running task with --trace)

What can I do?

It looks like you have an abandoned Rails install in your vendor folder already. You may have tried to freeze earlier only to see it fail. Delete the 'rails' directory in your /vendor folder, and then try again.

Hope that helps!

Thanks a ton! But now I get this in windows using InstantRails...
Freezing to the gems for Rails 1.2.5
Unpacked gem: 'I:/rails_programs/scrapbooking_new/vendor/rails/activesupport-1.4.4'
Unpacked gem: 'I:/rails_programs/scrapbooking_new/vendor/rails/activerecord-1.15.5'
rake aborted!
Permission denied - activerecord-1.15.5 or activerecord

Any thoughts?

@Cole - I have to apologize, as I have no idea. I am not familiar with InstantRails, nor am I familiar with developing with Ruby on Windows.

Maybe this will help? http://rubyforge.org/pipermail/instantrails-users/2006-May/000470.html

Worked great - thanks!

It REALLY helped me. Thanks

Post new comment

The content of this field is kept private and will not be shown publicly.

Powered by Drupal - Original Theme by Artinet - Theme Enhancements by Me