kenny-evitt

kenny-evitt

`Unable to load crypto library` error on macOS after running some Homebrew commands

I commented on this Elixir lang GitHub issue:

I just observed this error today. I hadn’t seen it before. I installed both Erlang and Elixir via asdf, long before today. My specific error:

$ mix dialyzer
Compiling 1 file (.ex)
Finding suitable PLTs
Checking PLT...
[:asn1, :certifi, :compiler, :connection, :crontab, :crypto, :db_connection, :decimal, :ecto, :ecto_sql, :elixir, :hackney, :idna, :jason, :kernel, :logger, :metrics, :mimerl, :pane, :postgrex, :public_key, :scribe, :ssl, :ssl_verify_fun, :stdlib, :telemetry, :tzdata, :unicode_util_compat]

10:45:53.045 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'dlopen(/Users/kenny/.asdf/installs/erlang/22.2.1/lib/crypto-4.6.3/priv/lib/crypto.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /Users/kenny/.asdf/installs/erlang/22.2.1/lib/crypto-4.6.3/priv/lib/crypto.so
  Reason: image not found'"
OpenSSL might not be installed on this system.


10:45:53.050 [warn]  The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library: \'dlopen(/Users/kenny/.asdf/installs/erlang/22.2.1/lib/crypto-4.6.3/priv/lib/crypto.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib\n  Referenced from: /Users/kenny/.asdf/installs/erlang/22.2.1/lib/crypto-4.6.3/priv/lib/crypto.so\n  Reason: image not found\''}}

** (UndefinedFunctionError) function :crypto.hash/2 is undefined (module :crypto is not available)
    (crypto) :crypto.hash(:sha, <<131, 116, 0, 0, 0, 22, 100, 0, 7, 99, 101, 114, 116, 105, 102, 105, 104, 7, 100, 0, 3, 104, 101, 120, 100, 0, 7, 99, 101, 114, 116, 105, 102, 105, 109, 0, 0, 0, 5, 50, 46, 53, 46, 49, 109, 0, 0, 0, 64, 56, ...>>)
    lib/mix/tasks/dialyzer.ex:384: Mix.Tasks.Dialyzer.dependency_hash/0
    lib/mix/tasks/dialyzer.ex:247: Mix.Tasks.Dialyzer.check_plt/1
    lib/mix/tasks/dialyzer.ex:172: Mix.Tasks.Dialyzer.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2

What I did do recently – yesterday – was install the Homebrew docutils package. I had to ‘overwrite links’ for some Python files/libraries – apparently, because of the impending Python 2 EOL, Homebrew is working on removing Python 2 dependencies.

I wonder if OpenSSL – the version I have installed – depends on those Python 2 libraries.

It seems now, based on replies to my comment in that same GitHub issue, the Homebrew inadvertently messed-up Erlang.

This existing post on this forum seems to cover my error:

In that post, several people confirmed that uninstalling and re-installing Erlang via asdf resolved the error. I’m going to try that now.

Marked As Solved

kenny-evitt

kenny-evitt

Uninstalling and re-installing Erlang via asdf did the trick!

Also Liked

pdgonzalez872

pdgonzalez872

Awesome! Let’s see what happens after a fresh reinstall.

But, you mentioned that it was Python that was crying, correct?

Where we discussed this before: Failed to load crypto library on mac os · Issue #5453 · elixir-lang/elixir · GitHub

kenny-evitt

kenny-evitt

This trick has worked now for two separate Elixir projects, both of which were broken by these errors.

monte

monte

Hi! I seem to have run into the same issue, however, the uninstalling and reinstalling Erlang with asdf does not resolve it, even if I specify the path to my version of openssl:

export KERL_CONFIGURE_OPTIONS="--with-ssl=$(brew --prefix openssl)"

Like @kenny-evitt I set up Elixir and Erlang long ago using asdf and it was working great until yesterday. The only change I made before things stopped working that seems like it could have caused this was installing emacs using brew. Now running any mix task an almost identical error to Kenny’s:

17:24:54.491 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'dlopen(/usr/local/Cellar/erlang/21.2.4/lib/erlang/lib/crypto-4.4/priv/lib/crypto.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
  Referenced from: /usr/local/Cellar/erlang/21.2.4/lib/erlang/lib/crypto-4.4/priv/lib/crypto.so
  Reason: image not found'"
OpenSSL might not be installed on this system.

17:24:54.492 [warn]  The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library: \'dlopen(/usr/local/Cellar/erlang/21.2.4/lib/erlang/lib/crypto-4.4/priv/lib/crypto.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib\n  Referenced from: /usr/local/Cellar/erlang/21.2.4/lib/erlang/lib/crypto-4.4/priv/lib/crypto.so\n  Reason: image not found\''}}

It seems like --with-ssl isn’t having any effect. I’m pretty sure that the brew update/install I did deleted openssl 1.0, I assume to force the upgrade to 1.1. I only have v1.1 installed.

I have tried using Kerl directly and several different versions of Erlang & Elixir with ‘–with-ssl’ specified. I keep getting the same error looking for libcrypto.1.0.0.dylib instead of libcrypto.1.1.0.dylib. I am on OS X Catalina (10.15.4) and XCode 11.4.1. I upgraded my XCode while trying to fix this since I was on a old version and getting warnings.

Anybody have any ideas why ‘–with-ssl’ isn’t working for specifying the version of OpenSSL? Am I missing something? It doesn’t seem like it is a linking problem (although brew does give me the same warning about refusing to link openssl@1.1).

I’ve also tried messing around with CFLAGS & tried setting LDFLAGS & CPPFLAGS but haven’t had any luck.

Last Post!

kylevsteger

kylevsteger

I had the same issue and reinstalling erlang didn’t help. I wound up removing my asdf install rm -rf ~/.asdf and reinstalling from git via their docs

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement