Digest::Digest is deprecated; use Digest

☆樱花仙子☆ 提交于 2019-12-07 16:07:10

问题


I am getting the following error

Digest::Digest is deprecated; use Digest

when i try to boot my rails server. I tried to search my source code for Digest::Digest but i am not using it anywhere. any idea how to solve that?

Only place i am using is

<% digest = OpenSSL::Digest.new('sha1') %>

@alias = Digest::MD5.hexdigest(phone)

回答1:


It is most likely used by one of the gems your app is dependent on.

install (unless already installed) ack tool and run the following command:

# of course, the path to your gems will be different
ack Digest::Digest /Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.1/gems/

It will show you whether any of the gems use it, and if yes - will show you the source code lines.

But basically there is not much you can do:

  1. Check, whether this gem has a newer version, which solves the deprecation warning
  2. Write a patch to the gem, which solves the warning and use patched verions (not cool idea IMO)
  3. Live with warning until gem maintainers work on that
  4. You can silence the depreciation warnings altogether with ActiveSupport::Deprecation.silenced = true (not cool idea as well IMO). There is also a way to silence specific warning, as @max says in comments):

    silenced = [
      /Digest::Digest is deprecated; use Digest/,
      /some other warning/,
    ]
    
    silenced_expr = Regexp.new(silenced.join('|'))
    
    ActiveSupport::Deprecation.behavior = lambda do |msg, stack|
      unless msg =~ silenced_expr
        ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:stderr].call(msg, stack)
      end
    end
    
  5. Do not use this gem



来源:https://stackoverflow.com/questions/40082768/digestdigest-is-deprecated-use-digest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!