Ruby: Loaderror - Library Not Found for Class Digest::Sha1 -- Digest/Sha1

Brew update breaks Rails s ( Open SSL + LoadError - library not found for class Digest::SHA1 — digest/sha1 )

This fix works for me.
Side note, I had to restart my mac for it to works. No idea why closing and opening a new session of my terminal was not enough though !

Error while running bundle install and rails server command

I got this same error, and it seems like that version of ruby got corrupted.

> bundle install
~/.rbenv/versions/2.5.6/lib/ruby/2.5.0/digest.rb:16:in `const_missing':
library not found for class Digest::SHA1 -- digest/sha1 (LoadError)

> ruby -r digest/sha1 -e 'p Digest::MD5'
...
Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
...

Using a mac with rbenv, I fixed it as follows:

> ruby -v
ruby 2.5.6p201 (2019-08-28 revision 67796) [x86_64-darwin18]

> rbenv install 2.5.6
...
continue with installation? (y/N) y
...
Installed ruby-2.5.6 to ~/.rbenv/versions/2.5.6

> ruby -r digest/sha1 -e 'p Digest::MD5'
Digest::MD5

bundle install worked after that.

Note: I got a lot of messages about running gem pristine, so just in case, I also ran:

> gem pristine --all

LoadError: dlopen(digest/sha1.bundle): Symbol not found: _rb_Digest_SHA1_Finish

Possible solutions:

  1. $ unset C_INCLUDE_PATH and reinstall Ruby

    This is the solution that worked for me.

    $ echo $C_INCLUDE_PATH

    If C_INCLUDE_PATH is set, it will break Ruby builds. Remove it from your environment; either temporarily with $ unset C_INCLUDE_PATH, or permanently (might be in .bashrc, .profile, .bash_profile); then reinstall ruby.

  2. It might be related to OpenSSL, RVM, XCode's Command Line Tools (gcc), or other build issues.

    See this answer if the previous solution didn't work.

Library not loaded (libcrypto)

I did a quick test:

rvm 2.6.5

To determine that ruby-2.6.5 was not installed, so I installed it:

rvm install "ruby-2.6.5"

rake db create aborted

There seems to be an issue with your ruby version.

Uninstall the current version and reinstall the same one and then try again.

rvm uninstall 2.3.8

and then

rvm install 2.3.8

Not loading library : rubygems/core_ext/kernel_require

The problem is that Ruby can't find the version of OpenSSL that it was compiled with. Reinstall OpenSSL (through whatever means you care to, e.g., brew install openssl), then reinstall Ruby:

rvm uninstall 2.3.1
rvm install 2.3.1

Once Ruby has been reinstalled, install your gems:

bundle install

Then retry your operation.

Getting Ruby code to work, creating SHA1 hash from given string and key

You need to install the ruby-hmac module. See this blog post for a gentle introduction.



Related Topics



Leave a reply



Submit