我尝试过在github上找到的几个解决方案(比如回滚到0.8.7),但uninitialized constant 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>'
如何在此特定设置上解决此问题?
答案 0 :(得分:0)
更新:重新安装了ruby -v'1.9.3'// rails -v'3.2.1'。 rake db:migrate
现在有效。
你看过这个解决方案了吗?这是similar stackoverflow question的最佳投票解决方案。链接上的其他答案可能适用。
将它放在上面的Rakefile中,需要'rake':
require 'rake/dsl_definition'