Rake提示uninitialized constant Rake::DSL解决办法

环境:Ruby 1.9.1/Rails 3.0.9/Rake 0.9.2

在运行rake db:create的时候提示

rake aborted!
uninitialized constant Rake::DSL
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:Rake>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rdoc-3.6.1/lib/rdoc/task.rb:37:in `require'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rdoc-3.6.1/lib/rdoc/task.rb:37:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.rake:2:in `require'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.rake:2:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `block in <top (required)>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top (required)>'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in `require'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in `initialize_tasks'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:in `load_tasks'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
/usr/local/sharephoto/Rakefile:7:in `<top (required)>'
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/local/ruby/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/local/ruby/bin/rake:31:in `<main>'

 解决方法:

打开RakeFile文件,在require 'rake'上面加入

require 'rake/dsl_definition'
 

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