耙0.9.0'未定义方法'任务''

时间:2011-05-20 18:09:50

标签: ruby-on-rails-3 rake

Gemfile只包含rails 3.0.7和sqlite3,突然rake不会在任何app上运行。运行'rake db:migrate'时出错 完整跟踪输出:

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/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/Users/codywright/.rvm/gems/ruby-1.9.2-p180@global/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>'

5 个答案:

答案 0 :(得分:8)

我做了:sudo gem uninstall rake -v 0.9然后将gem 'rake', '0.8.7'添加到我的gem文件中。

答案 1 :(得分:5)

您可以通过添加以下行来修复您的application.rb文件,而不是降级您的Rake:

include Rake::DSL

只需在类Application中添加它,你应该很好!

示例application.rb:

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

答案 2 :(得分:3)

Gemfile中的

gem 'rake', '0.8.7'如果捆绑包抱怨rake lock'0.9.0',则可能还需要运行bundle update rake

以下是rake github页面https://github.com/jimweirich/rake/issues/33

上的问题

答案 3 :(得分:2)

我在jruby。以下是解决问题的确切命令。

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

编辑Gemfile:在gem'trail'之后添加:

gem 'rake', '0.8.7'

最后运行:

jruby -S bundle update rake

答案 4 :(得分:0)

在命令提示符下运行这两行。它将删除rake 0.9.0。 用你的用户名替换它显示“用户名”

GEM_HOME ='/ Users/username/.rvm/gems/ruby-1.9.2-p180@global'GEM_PATH='/Users/username/.rvm/gems/ruby-1.9.2-p180@global'gemony卸载rake

GEM_HOME ='/ Users / username / .rvm / gems / ruby​​-1.9.2-p180'GEM_PATH ='/ Users / username / .rvm / gems / ruby​​-1.9.2-p180'gem uninstall rake

然后安装正确的宝石:

rvm gem install mysql2 -v 0.2.7

rvm gem install rake -v 0.8.7

更新MySQL gem(此处显示x86_64 intel安装的声明):

env ARCHFLAGS =“ - arch x86_64”gem install mysql - --with-mysql-config = / usr / local / mysql / bin / mysql_config

创建新应用时:

rails new -d mysql

您不需要更改gemfile或使用bundle exec

我希望这是有道理的。这篇文章不会让我将语法布局在可读的地方。