[验证]绑定rails1.2.6至Rails程序问题

Rails - Uninitialized Constant Gem::GemRunner Error
I'm using Gem 1.0.1 and Rails 1.2.6 that pre-installed by Mac OS X 10.5.2 (AKA Leopard). When I attempted to run rake rails:freeze:gems, I got this error:

uninitialized constant Gem::GemRunner
Since Gem version 0.9.5, gem_runner is not required automatically for the rake tasks. To solve this problem, just edit framework.rake file(For me, it is located in 'usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/tasks'.), and add the required line in the rails:freeze:gems task.

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' #<---insert here
      Gem.manage_gems
After that, *DO NOT* forget to remove the directory 'rails' in your project_dicectory/vendor/ before you try to freeze the rails again.

rm -rf project_directory/vendor/rails
Even when you finished all of these steps, you may still get error:

Freezing to the gems for Rails 1.2.6
ERROR:  While executing gem ... (Gem::Exception)
    Cannot load gem at [/Library/Ruby/Gems/1.8/cache/activesupport-1.4.4.gem]
This is because your Rails 1.2.6 was shipped with Leopard instead of installing it by gems, so there're no rails files in the cache directory. I didn't want to reinstall or upgrade the Rails, so my solution was use rake rails:freeze:edge like so:

rake rails:freeze:edge TAG=rel_1-2-6
The command will checkout the rails 1.2.6 from the remote repository to your local machine.

你可能感兴趣的:(cache,Ruby,ActiveRecord,Rails,rubygems)