2011-05-20 33 views
17

Gemfile只包含rails 3.0.7和sqlite3,所有突然的rake不会在任何应用上运行。运行'rake db:migrate'时启动错误 完整跟踪输出:Rake 0.9.0'undefined method'task''

rake aborted! 
undefined method `task' for #<NotWorking::Application:0x00000100ccc328> 
/Users/codywright/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks' 
/Users/codywright/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks' 
/Users/codywright/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing' 
/Users/codywright/Code/Rails/not_working/Rakefile:7:in `<top (required)>' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/lib/rake/application.rb:59:in `run' 
/Users/codywright/.rvm/gems/[email protected]/gems/rake-0.9.0/bin/rake:31:in `<top (required)>' 
/Users/codywright/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load' 
/Users/codywright/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>' 
+0

看到这里http://stackoverflow.com/questions/5287121/undefined-method-task-using-rake-0-9-0-beta-4 – Rob 2011-05-20 19:05:53

+0

好消息! Rails 3.0.8.rc1已经解决了这个问题,请参阅https://github.com/rails/rails/commit/83f257fc4862642af29056cb5b7dfef6e1303754 – 2011-05-26 01:10:36

回答

8

我所做的:sudo gem uninstall rake -v 0.9加入gem 'rake', '0.8.7'到我的宝石文件。

0

运行这两条线在命令提示符下的问题。它会删除耙0.9.0。 将您的用户名替换为显示“用户名”的地方

GEM_HOME='/Users/username/.rvm/gems/[email protected]'GEM_PATH ='/ Users/username/.rvm/gems/[email protected]'gem uninstall rake

GEM_HOME ='/ Users/username/.rvm/gems/ruby​​-1.9.2-p180'GEM_PATH ='/ Users/username/.rvm/gems /ruby-1.9.2-p180' 宝石卸载耙

然后安装正确的宝石:

RVM创业板安装mysql2 -v 0.2.7

RVM创业板安装耙-v 0.8.7

更新MySQL的宝石(statment这里显示了英特尔x86_64的安装):

ENV ARCHFLAGS = “ - 拱x86_64的” 宝石安装mysql - --with-mysql的-config =在/ usr /本地/ MySQL的/斌/ mysql_config

当你创建一个新的应用程序:

轨新-d mysql的

你不应该需要改变的Gemfile或使用捆绑EXEC

我希望这是有道理的。这篇文章不会让我布置它可读的语法。

+0

你基本上写了和[@Tyler]一样的东西(http://stackoverflow.com/questions/ 6075997 /耙0-9-0-未定义-方法任务/ 6077849#6077849)。不同之处在于他是在一行中完成的,并且添加了不相关的信息。重点是什么?请仔细阅读[FAQ](http://stackoverflow.com/faq) – Andrei 2011-05-22 04:33:45

2

我在jruby上。这里是确切的命令,让我摆脱了这个问题。

jruby -S gem uninstall rake 
jruby -S gem install rake -v 0.8.7 

编辑的Gemfile:添加这种宝石之后 '轨':

gem 'rake', '0.8.7' 

最后运行:

jruby -S bundle update rake 
5

而不是降级的耙,你可以修复你的application.rb中的文件添加该行:

include Rake::DSL 

只需在类应用程序中添加,你应该很好!

示例应用程序。RB:

module AppName 
    class Application < Rails::Application 
    include Rake::DSL 
    end 
end