17

Gemfile only contains rails 3.0.7 and sqlite3, all of a sudden rake will not run on any apps.The error started when running 'rake db:migrate' Full trace output:

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>'
Gazler
  • 83,029
  • 18
  • 279
  • 245
cmwright
  • 3,406
  • 5
  • 26
  • 33
  • see here http://stackoverflow.com/questions/5287121/undefined-method-task-using-rake-0-9-0-beta-4 – Rob May 20 '11 at 19:05
  • Good news! Rails 3.0.8.rc1 has fixed this issue, see https://github.com/rails/rails/commit/83f257fc4862642af29056cb5b7dfef6e1303754 – James Chen May 26 '11 at 01:10

5 Answers5

8

I did: sudo gem uninstall rake -v 0.9 then added gem 'rake', '0.8.7' to my gem file.

Tyler
  • 81
  • 2
5

Rather than downgraded your Rake, you can fix your application.rb file by adding the line:

include Rake::DSL

Just add that within the class Application and you should be good!

Example application.rb:

module AppName
  class Application < Rails::Application
   include Rake::DSL
  end
end
Tom Rossi
  • 11,604
  • 5
  • 65
  • 96
3

gem 'rake', '0.8.7' in Gemfile works, if may also need to run bundle update rake if bundler complains about rake locked '0.9.0'.

Here is the issue on rake github page https://github.com/jimweirich/rake/issues/33

Fabio
  • 18,856
  • 9
  • 82
  • 114
2

I am on jruby. Here are the exact commands that got me rid of the problem.

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

edit Gemfile: Add this after gem 'rails':

gem 'rake', '0.8.7'

finally run:

jruby -S bundle update rake
clemens
  • 21
  • 1
0

Run these 2 lines at the command prompt. It will remove rake 0.9.0. substitute your username where it shows "username"

GEM_HOME='/Users/username/.rvm/gems/ruby-1.9.2-p180@global' GEM_PATH='/Users/username/.rvm/gems/ruby-1.9.2-p180@global' 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' gem uninstall rake

Then install the correct gems:

rvm gem install mysql2 -v 0.2.7

rvm gem install rake -v 0.8.7

Update the MySQL gem (statment here show for x86_64 intel install):

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

When you create a new app:

rails new -d mysql

you shouldn't need to change the gemfile or use bundle exec

I hope this makes sense. This post wont let me layout the syntax where it is readable.

  • you basically wrote the same thing as [@Tyler](http://stackoverflow.com/questions/6075997/rake-0-9-0-undefined-method-task/6077849#6077849). The difference is that he did it in one line, and you added irrelevant information. What's the point? Please, [read the FAQ](http://stackoverflow.com/faq) carefully – Andrei May 22 '11 at 04:33