我遇到了'未初始化的常量Rake :: DSL'这个问题。 我试图在Gemfile中添加gem'rake','0.8.7',但它没有用。还有其他方法可以解决这个问题吗?谢谢!
n177-p118:testapp shuang$ rake db:migrate --trace
(in /Users/shuang/rails/testapp)
rake aborted!
uninitialized constant Rake::DSL
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2503:in `const_missing'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks/documentation.rake:11
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:15:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:15
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:6:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:6
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:289:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:289:in `initialize_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `instance_exec'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:424:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:145:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/shuang/rails/testapp/rakefile:8
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2383:in `load'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2383:in `raw_load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2017:in `load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2016:in `load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2000:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:31
答案 0 :(得分:1)
这可能是非常糟糕的形式,但将此添加到我的Rakefile顶部对我有用:
module Rake
module DSL
end
end
答案 1 :(得分:0)
检查你的gemfile.lock,它必须是一个版本的rake,它是> 0.8.7。如果是,则删除all然后删除所有版本的实例或删除gemfile.lock的所有内容,然后再次进行bundle install。
答案 2 :(得分:-1)
您也可以尝试运行
bundle exec rake db:migrate