NoMethodError: undefined method `last_comment' after upgrading to rake 11
I have been encountering the problem described in the thread above. To recap, running rake
produces the following error:
NoMethodError: undefined method `last_comment' for #<Rake::Application:0x00000002b15ba0>
The consensus in the thread above is that the 'last_comment' method is deprecated in rake 11
(replaced by 'last_description').
The answers claim the solution is to either pin rake
to version 10.5 in the Gemfile, which still calls 'last_comment', or upgrade to rake 12
and rspec >3.5
, where the dependency has been resolved. I've tried both solutions, and I still get the same error.
Update
The bundle exec
trace suggests that rake
is using the system gem for rspec
, which is only 2.9. How do I either upgrade the system gem or get the bundler to recognize the version I've specified in my gem path?
Gemfile
gem "rake"
gem "rspec", '>= 3.7'
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
rake (12.3.0)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
PLATFORMS
ruby
DEPENDENCIES
rake
rspec (>= 3.7)
BUNDLED WITH
1.16.1
Versions
ruby 2.3.1
Rails 4.2.6
rake, version 12.3.0
RSpec 3.7
- rspec-core 3.7.1
- rspec-expectations 3.7.0
- rspec-mocks 3.7.0
- rspec-rails 3.7.2
- rspec-support 3.7.0
Traces
When I run rake
:
/var/lib/gems/2.3.0/gems/rspec-core-2.99.2/lib/rspec/core/rake_task.rb:143:in `initialize'
/home/alexander/Documents/Coding/Ruby/learn_ruby/Rakefile:8:in `new'
/home/alexander/Documents/Coding/Ruby/learn_ruby/Rakefile:8:in `<top (required)>'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/rake_module.rb:29:in `load'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/rake_module.rb:29:in `load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:703:in `raw_load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:104:in `block in load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:103:in `load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:82:in `block in run'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/var/lib/gems/2.3.0/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
When I run bundle exec rake
:
Gem::LoadError: can't activate rspec (~> 2), already activated rspec-3.7.0. Make sure all dependencies are added to Gemfile.
/var/lib/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/rubygems_integration.rb:404:in `block (2 levels) in replace_gem'
/home/alexander/Documents/Coding/Ruby/learn_ruby/Rakefile:2:in `<top (required)>'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/rake_module.rb:29:in `load'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/rake_module.rb:29:in `load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:703:in `raw_load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:104:in `block in load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:103:in `load_rakefile'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:82:in `block in run'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/var/lib/gems/2.3.0/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/var/lib/gems/2.3.0/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
When I just run bundle
:
Using rake 12.3.0
Using bundler 1.16.1
Using diff-lcs 1.3
Using rspec-support 3.7.1
Using rspec-core 3.7.1
Using rspec-expectations 3.7.0
Using rspec-mocks 3.7.0
Using rspec 3.7.0
When I run bundle show rspec-rails
, it says that it could not find the gem.