Rake 0.9.0 'undefined method 'task' ' [duplicate]
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/ge开发者_运维知识库ms/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>'
I did: sudo gem uninstall rake -v 0.9
then added gem 'rake', '0.8.7'
to my gem file.
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
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
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
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.
精彩评论