Rails 3.2.1,使用 rake db:migrate 时未初始化的常量 Rake::DSL

发布于 2025-01-03 01:07:41 字数 5423 浏览 0 评论 0原文

我尝试了在 github 上找到的几种解决方案(例如回滚到 rake 0.8.7),但未初始化的常量 Rake::DSL 从未消失。

输出:

bartolsthoorn@server-006:~/apps/dev$ rake db:migrate
(in /home/bartolsthoorn/apps/dev)
rake aborted!
uninitialized constant Rake::DSL
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb:6:in `<module:Rake>'
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb:3:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/testtask.rb:4:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/test_unit/testing.rake:2:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/test_unit/railtie.rb:12:in `block in <class:TestUnitRailtie>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `instance_exec'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `block in load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/engine.rb:423:in `block in load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application/railties.rb:8:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application/railties.rb:8:in `all'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/engine.rb:423:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application.rb:145:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/bartolsthoorn/apps/dev/Rakefile:9:in `<top (required)>'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `load'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/opt/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:1991:in `run'
/opt/bin/rake:31:in `<main>'

我的包:

Gems included by the bundle:
  * POpen4 (0.1.4)
  * Platform (0.4.0)
  * RedCloth (4.2.9)
  * actionmailer (3.2.1)
  * actionpack (3.2.1)
  * activemodel (3.2.1)
  * activerecord (3.2.1)
  * activeresource (3.2.1)
  * activesupport (3.2.1)
  * arel (3.0.0)
  * authlogic (3.1.0)
  * builder (3.0.0)
  * bundler (1.0.7)
  * erubis (2.7.0)
  * hike (1.2.1)
  * i18n (0.6.0)
  * jammit (0.6.5)
  * journey (1.0.1)
  * jquery-rails (2.0.0)
  * json (1.6.5)
  * mail (2.4.1)
  * mime-types (1.17.2)
  * multi_json (1.0.4)
  * open4 (1.3.0)
  * polyglot (0.3.3)
  * rack (1.4.1)
  * rack-cache (1.1)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.2.1)
  * railties (3.2.1)
  * rake (0.9.2.2)
  * rdoc (3.12)
  * sprockets (2.1.2)
  * sqlite3 (1.3.5)
  * sqlite3-ruby (1.3.3)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.31)
  * yui-compressor (0.9.6)

当我将 rake 设置为 0.8.7 时,结果是:

bartolsthoorn@server-006:~/apps/dev$ bundle show rake
/home/bartolsthoorn/.bundle/gems/rake-0.8.7
bartolsthoorn@server-006:~/apps/dev$ bundle exec rake db:migrate
(in /home/bartolsthoorn/apps/dev)
rake aborted!
uninitialized constant Rake::DSL
/home/bartolsthoorn/apps/dev/Rakefile:9:in `<top (required)>'
(See full trace by running task with --trace)
bartolsthoorn@server-006:~/apps/dev$ rake db:migrate
(in /home/bartolsthoorn/apps/dev)
rake aborted!
uninitialized constant Rake::DSL
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks/documentation.rake:11:in `<class:RDocTaskWithoutDescriptions>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks/documentation.rake:10:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks.rb:15:in `block in <top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks.rb:6:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks.rb:6:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application.rb:289:in `block in initialize_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `instance_exec'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `block in load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/engine.rb:424:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application.rb:145:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/bartolsthoorn/apps/dev/Rakefile:9:in `<top (required)>'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `load'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/opt/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:1991:in `run'
/opt/bin/rake:31:in `<main>'

如何在此特定设置上修复此问题?

I have tried several solutions I found on github (like rolling back to rake 0.8.7) but the uninitialized constant Rake::DSL never disappeared.

Output:

bartolsthoorn@server-006:~/apps/dev$ rake db:migrate
(in /home/bartolsthoorn/apps/dev)
rake aborted!
uninitialized constant Rake::DSL
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb:6:in `<module:Rake>'
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb:3:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/rake-0.9.2.2/lib/rake/testtask.rb:4:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/test_unit/testing.rake:2:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/test_unit/railtie.rb:12:in `block in <class:TestUnitRailtie>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `instance_exec'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `block in load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/engine.rb:423:in `block in load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application/railties.rb:8:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application/railties.rb:8:in `all'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/engine.rb:423:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application.rb:145:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/bartolsthoorn/apps/dev/Rakefile:9:in `<top (required)>'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `load'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/opt/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:1991:in `run'
/opt/bin/rake:31:in `<main>'

My bundle:

Gems included by the bundle:
  * POpen4 (0.1.4)
  * Platform (0.4.0)
  * RedCloth (4.2.9)
  * actionmailer (3.2.1)
  * actionpack (3.2.1)
  * activemodel (3.2.1)
  * activerecord (3.2.1)
  * activeresource (3.2.1)
  * activesupport (3.2.1)
  * arel (3.0.0)
  * authlogic (3.1.0)
  * builder (3.0.0)
  * bundler (1.0.7)
  * erubis (2.7.0)
  * hike (1.2.1)
  * i18n (0.6.0)
  * jammit (0.6.5)
  * journey (1.0.1)
  * jquery-rails (2.0.0)
  * json (1.6.5)
  * mail (2.4.1)
  * mime-types (1.17.2)
  * multi_json (1.0.4)
  * open4 (1.3.0)
  * polyglot (0.3.3)
  * rack (1.4.1)
  * rack-cache (1.1)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.2.1)
  * railties (3.2.1)
  * rake (0.9.2.2)
  * rdoc (3.12)
  * sprockets (2.1.2)
  * sqlite3 (1.3.5)
  * sqlite3-ruby (1.3.3)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.31)
  * yui-compressor (0.9.6)

When I set rake to 0.8.7 this is the result:

bartolsthoorn@server-006:~/apps/dev$ bundle show rake
/home/bartolsthoorn/.bundle/gems/rake-0.8.7
bartolsthoorn@server-006:~/apps/dev$ bundle exec rake db:migrate
(in /home/bartolsthoorn/apps/dev)
rake aborted!
uninitialized constant Rake::DSL
/home/bartolsthoorn/apps/dev/Rakefile:9:in `<top (required)>'
(See full trace by running task with --trace)
bartolsthoorn@server-006:~/apps/dev$ rake db:migrate
(in /home/bartolsthoorn/apps/dev)
rake aborted!
uninitialized constant Rake::DSL
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks/documentation.rake:11:in `<class:RDocTaskWithoutDescriptions>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks/documentation.rake:10:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks.rb:15:in `block in <top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks.rb:6:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/tasks.rb:6:in `<top (required)>'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application.rb:289:in `block in initialize_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `instance_exec'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `block in load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `each'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie.rb:184:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/engine.rb:424:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/application.rb:145:in `load_tasks'
/home/bartolsthoorn/.bundle/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/bartolsthoorn/apps/dev/Rakefile:9:in `<top (required)>'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `load'
/opt/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/opt/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/opt/lib/ruby/1.9.1/rake.rb:1991:in `run'
/opt/bin/rake:31:in `<main>'

How to fix this on this specific setup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生路 2025-01-10 01:07:41

更新:全新安装了 ruby​​ -v '1.9.3' //rails -v '3.2.1'。 rake db:migrate 现在可以工作了。

您检查过这个解决方案吗?这是类似的 stackoverflow 问题的投票最高的解决方案< /a>.链接上的其他答案可能适用。

将其放入上面的 Rakefile require 'rake':
需要“rake/dsl_definition”

UPDATE: Did a fresh install of ruby -v '1.9.3' // rails -v '3.2.1'. rake db:migrate works now.

Did you check out this solution? It was the top voted solution for a similar stackoverflow question. Other answers on the link may be applicable.

Put this in your Rakefile above require 'rake':
require 'rake/dsl_definition'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文