如何检测Rake中导致弃用警告的原因

当我bundle exec rake -T (或bundle exec rake ),我得到了弃用警告:

 Andrews-Air:nabu agrimm$ bundle exec rake --trace -T [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. [DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead. rake about # List versions of all Rails frameworks and the environment [snip] 

虽然不是真正相关的,这里是Gemfile:

 source 'https://rubygems.org' gem 'rails', '~> 3.2.22.2' gem 'mysql2' group :assets do gem 'coffee-rails', '~> 3.2.1' gem 'compass-rails' gem 'therubyracer' gem 'libv8' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem 'haml-rails' gem 'to-csv', :require => 'to_csv' gem 'kaminari' gem 'oai' gem 'analytical' gem 'country-select' gem 'activeadmin' gem 'sass-rails', '~> 3.2.3' gem 'meta_search', '>= 1.1.0.pre' gem 'devise', '2.2.3' gem 'cancancan', '~> 1.12.0' gem 'squeel' gem 'nilify_blanks' gem 'sunspot_rails' gem 'sunspot_solr' gem 'unicorn' gem 'ruby-filemagic' gem 'capistrano' gem 'capistrano-ext' gem 'capistrano-unicorn' gem 'rollbar', '~> 2.8.3' gem 'newrelic_rpm' gem 'progress_bar' gem 'paper_trail', '~> 2' gem 'quiet_assets' gem 'roo', '~> 2.1.0' gem 'roo-xls', :github => 'roo-rb/roo-xls', :ref => '0a5ef88' gem 'streamio-ffmpeg' gem 'rake' gem 'rmagick' gem 'whenever', :require => false group :development, :test do gem 'turn', '~> 0.8.3', :require => false gem 'rspec-rails', '~> 2.0' gem 'sextant' gem 'thin' gem 'spring' gem 'spring-commands-rspec' gem 'pry' gem 'pry-rails' gem 'letter_opener' gem 'guard-bundler' gem 'guard-rails' gem 'guard-rspec' gem 'guard-sunspot' gem 'rb-inotify', :require => RUBY_PLATFORM.include?('linux') ? 'rb-inotify' : false gem 'rb-fsevent', :require => RUBY_PLATFORM.include?('darwin') ? 'rb-fsevent' : false end group :development do gem 'annotate' gem 'binding_of_caller' gem 'better_errors' gem 'rubocop' end group :test do gem 'capybara' gem 'poltergeist' gem 'factory_girl_rails' gem 'database_cleaner' gem 'email_spec' gem 'launchy' end 

做一个git grep -i last_comment表明它不在我的代码中 – 大概是在第三方gem中。

如何解决导致弃用警告的原因?

我发现从rake-11.1.0/lib/rake/task_manager.rb:10修改warn线更容易。

对于我来说,违规的gem是rspec( 固定在3.4.4 )和rubocop( 固定在0.38.0 )。

尝试更新gem "rspec-rails", "~> 3.4.4" ,解决了我的弃用警告。

你可以recursion grep你的gem,与:

 grep -r last_comment /path/to/gems 

这不是rspec错误 ,错误来自rake几个星期前提交了一个提交警告,这里有一个后续。

似乎last_description已经在使用last_description不是last_comment 。 如果可能的话,尝试更新到更新版本的rspec-core Gem,比如@ chris-scottbuild议的。 我跑了伎俩

bundle update rspec-core

如本文所述,您可以执行以下操作:

 # application.rb ActiveSupport::Deprecation.debug = true 

这会给你完整的弃用痕迹。