Ruby - Digest::Digest is deprecated; Use Digest
Solution 1
Borrowing the reply from this thread
OpenSSL::Digest::Digest has been discouraged to use from very ancient era such as Ruby 1.8 and finally was deprecated recently.
If you search for the error message, you will see that a lot of gems, including fog, were still using the deprecated syntax.
I assume it will take a while before all the gems will be updated. If you came across the deprecation in one of the libs you use, I encourage you to report it to the maintainer.
Here's a few examples
- https://github.com/fog/fog/pull/2473
- https://github.com/alexreisner/geocoder/pull/580
- https://github.com/ruby/ruby/pull/446
It's likely your Rails app depends on a gem that is using that old syntax.
Solution 2
If you're using bundler, a good way to find out what is causing the problem is to grep through all the gems defined in your Gemfile
:
# grep (ack or ag) the problem code
bundle show --paths | xargs grep -r Digest::Digest
# here was my output
~/.gem/ruby/2.1.0/gems/fog-1.15.0/lib/fog/cloudstack.rb: @@digest = OpenSSL::Digest::Digest.new('sha1')
~/.gem/ruby/2.1.0/gems/fog-1.15.0/lib/fog/core/hmac.rb: @digest = OpenSSL::Digest::Digest.new('sha1')
~/.gem/ruby/2.1.0/gems/fog-1.15.0/lib/fog/core/hmac.rb: @digest = OpenSSL::Digest::Digest.new('sha256')
# update appropriate gems (in my case fog)
gem install fog
bundle update fog
Also make sure you aren't locked on a gem version in your Gemfile.
# change
gem 'fog', '~> 1.15.0'
# to
gem 'fog', '~> 1.0'
# or omit the version if you are a cowboy/girl
Solution 3
Use OpenSSL::Digest
instead of deprecated OpenSSL::Digest::Digest
![stephenmurdoch](https://i.stack.imgur.com/AtDIv.jpg?s=256&g=1)
stephenmurdoch
Updated on June 18, 2022Comments
-
stephenmurdoch about 2 years
I've been getting this warning whenever I run my tests or start rails server.
When I run grep from .rvm folder I see the following:
grep -R 'Digest::Digest' . ./rubies/ruby-2.1.0/lib/ruby/2.1.0/openssl/digest.rb: warn('Digest::Digest is deprecated; Use Digest') - additional references to openssl and ruby 2.1.0
So it looks like it's a Ruby 2.1.0 bug. Are there any fixes? There are no patches available yet as far as I can tell.
Whilst my app uses Fog and a bunch of other gems that have issues relating to this message, I'm using patched versions that don't have the bug. So I reckon Ruby is at fault here.
-
stephenmurdoch over 10 yearsThanks, I'll report it, and wait for it to go away.
-
nathany over 10 yearss3_direct_upload is another gem with this deprecation warning: github.com/waynehoover/s3_direct_upload/issues/148
-
CafeHey over 9 yearsMine was coming from the asset_sync gem which had an old version of fog as a dependency. bundle update asset_sync fixed it for me.
-
gitb over 8 yearsTried this trick both locally and on dev and the grep came back empty.
-
mraaroncruz over 8 years@gitb Try to grep just a part of the name like just
Digest
. Maybe they have it split across lines. Besides that it is either in your code (so grep your project code) or I have no idea :)