1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Rails][IRB][Pry]SourceAnnotationExtractor is deprecated 解決法

Posted at

起こったこと

Rails6binding.pry などIRBTab 補完しようとすると

以下のようなエラーが出る。
(Warining だけど見づらい。)


[WARN ] DEPRECATION WARNING: SourceAnnotationExtractor is deprecated! 
Use Rails::SourceAnnotationExtractor instead. 
(called from new_card at /home/user/dev/rails/test-proj/app/controllers/app_controller.rb:36)

解決法

とりあえず
以下のパッチを config/initializers に置く。

config/initializers/active_support_backports.rb
# Fix IRB deprecation warning on tab-completion.
#
# Backports the fix for https://github.com/rails/rails/issues/37097
# from https://github.com/rails/rails/pull/37100
#
# Backports proposed fix for https://github.com/rails/rails/pull/37468
# from https://github.com/rails/rails/pull/37468
module ActiveSupportBackports

  warn "[DEPRECATED] #{self} should no longer be needed. Please remove!" if Rails.version >= '6.1'

  def self.prepended(base)
    base.class_eval do
      delegate :hash, :instance_methods, :respond_to?, to: :target
    end
  end
end

module ActiveSupport
  class Deprecation
    class DeprecatedConstantProxy
      prepend ActiveSupportBackports
    end
  end
end

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?