Thursday, July 06, 2017

NoMethodError: undefined method `last_comment' for #

I found this error for rake new version:
rake aborted!
NoMethodError: undefined method `last_comment' for #<Rake::Application:0x000000027b6798>
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/rspec-core-2.99.2/lib/rspec/core/rake_task.rb:143:in `initialize'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/rspec-rails-2.99.0/lib/rspec/rails/tasks/rspec.rake:11:in `new'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/rspec-rails-2.99.0/lib/rspec/rails/tasks/rspec.rake:11:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `load'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `block in load'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `load'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/rspec-rails-2.99.0/lib/rspec-rails.rb:10:in `block in <class:Railtie>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/railtie.rb:194:in `instance_exec'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/railtie.rb:194:in `block in load_tasks'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/railtie.rb:194:in `each'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/railtie.rb:194:in `load_tasks'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/engine.rb:423:in `block in load_tasks'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/application/railties.rb:8:in `each'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/application/railties.rb:8:in `all'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/engine.rb:423:in `load_tasks'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/application.rb:145:in `load_tasks'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/railties-3.2.22.5/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/sachin/rails_projects/sachin/Rakefile:7:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p545@oomph-sachin/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
(See full trace by running task with --trace)

Solution:

Rake 11.0.1 removes the methodlast_comment which Rails 2.3 rspec-core (< 3.4.4) uses. Therefore until/if a patch is released we need to pin rake to an older version in Gemfile:


`gem 'rake', '< 11.0'`


Then `bundle update rake`


It will resolve your issue.
Reactions:

0 comments:

Post a Comment