Getting error: Unable to load crypto library.. OpenSSL might not be installed on this system

dev@dev:\~/discuss$ iex -S mix phx.server
Erlang/OTP 25 \[erts-13.1.5\] \[source\] \[64-bit\] \[smp:16:2\] \[ds:16:2:10\] \[async-threads:1\] \[jit:ns\]

\[error\] Unable to load crypto library. Failed with error:
“:load_failed, Failed to load NIF library /home/dev/.asdf/installs/erlang/25.2.3/lib/crypto-5.1.2/priv/lib/crypto: ‘libcrypto.so.1.1: cannot open shared object file: No such file or directory’”
OpenSSL might not be installed on this system.

\[warning\] The on_load function for module crypto returned:
{:error,
{:load_failed,
‘Failed to load NIF library /home/dev/.asdf/installs/erlang/25.2.3/lib/crypto-5.1.2/priv/lib/crypto: 'libcrypto.so.1.1: cannot open shared object file: No such file or directory'’}}

\[notice\] Application plug exited: Plug.Application.start(:normal, [ ]) returned an error: shutdown: failed to start child: Plug.Upload
\*\* (EXIT) an exception was raised:
\*\* (UndefinedFunctionError) function :crypto.strong_rand_bytes/1 is undefined (module :crypto is not available)
(crypto 5.1.2) :crypto.strong_rand_bytes(3)
(plug 1.16.1) lib/plug/upload.ex:210: Plug.Upload.init/1
(stdlib 4.2) gen_server.erl:851: :gen_server.init_it/2
(stdlib 4.2) gen_server.erl:814: :gen_server.init_it/6
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
\[notice\] Application telemetry exited: :stopped
\[notice\] Application plug_crypto exited: :stopped
\[notice\] Application mime exited: :stopped
\[notice\] Application eex exited: :stopped
\[notice\] Application runtime_tools exited: :stopped
\*\* (Mix) Could not start application plug: Plug.Application.start(:normal, [ ]) returned an error: shutdown: failed to start child: Plug.Upload
\*\* (EXIT) an exception was raised:
\*\* (UndefinedFunctionError) function :crypto.strong_rand_bytes/1 is undefined (module :crypto is not available)
(crypto 5.1.2) :crypto.strong_rand_bytes(3)
(plug 1.16.1) lib/plug/upload.ex:210: Plug.Upload.init/1
(stdlib 4.2) gen_server.erl:851: :gen_server.init_it/2
(stdlib 4.2) gen_server.erl:814: :gen_server.init_it/6
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
dev@dev:\~/discuss$
1 Like

You have to install libcrypto, usually part of OpenSSL.

Details on how to do that should be described in your Linux Distributions manual.

2 Likes

That’s the problem I was gifted this computer without any manual, I know that the distributor id is Ubuntu, I’m running Ubuntu 24.04.3 LTS.

1 Like

With “your Linux Distributions manual” I meant whatever ressources you can find through the Internet.

Though for Ubuntu its very likey apt install openssl, maybe openssl-dev

3 Likes

Hello and Thank you. I will get back to you on this matter, I am thankful for your help. I hope that we can keep in touch.

2 Likes

I just did Sudo apt install openssl and it states that it’s already installed, In my problem it states that it’s not installed.

1 Like

Therefore I have asked you to also try the openssl-dev

1 Like

Wait, I have read the original error again. It is asking for version 1.1 of the library. That has been deprecated many years ago and hasn’t been shipped in Ubuntu since 22.04.

I also have realized, that you are using OTP 25.2. The prebuilt versions might indeed still link to that old version. If you are lucky a very recent 25.3.2.21 might link the correct libcrypto by default, as it is a quite recent release.

If not you might have to force a sourcebuild or try even OTP 26 or newer.

I haven’t used ASDF in ages, so I do not remember how to enforce an erlang build from source.

4 Likes

I tried exactly what you said and it didn’t work out because it states that openssl is already installed on my laptop. I know that I don’t have a lot of information about this, I hope that you will keep helping me until I can solve this issue.

If you know how I can manually install and or update these things that would be very helpful, I’m sorry for being so clueless here.

All I remember about asdf is, that there should be a .tool-versions in your project, which you have to adjust. But in which way, you have to check in the documentation of the asdf-erlang plugin you use.

Quick search reveals this: How install libssl1.1 on ubuntu 22.04 · GitHub

However I would not recommend it. It’s best if you use latest Erlang and Elixir and install them through mise (or asdf). It’s a lost battle to try and coax old Ubuntu versions into having older libraries.

I have tried to update erlang and Elixir and it says that they both are up to date. I hope that you can help me.

Is there anyway that you can help me to access that and check on it and see if I can update anything and get back to you.

I appreciate that you are being polite about your problem but you seem to miss basics of managing a developer machine.

You don’t upgrade Erlang and Elixir when you use a version manager like asdf. You simply install higher versions, separately.

Have you read on how to use asdf?

Unfortunately I was given this amazing computer with no manual and I have had to learn everything myself without any help from the person who gave it to me and by watching course videos on Udemy about Elixir and Phoenix Framework. How do I update it then if I may ask, I do have over a year of studying programming and learning by myself how to code.

Computers don’t come with a manual, they never really came. The last computer I had that had a real manual has been my commodore C64…

It totally depends!

From the error above, we can only see that your Erlang is managed through asdf.

We can not say whether this is a global or a project specific version. And even then, there are plenty of ways to override the version permanently or temporarily.

My suggestion is to read yourself into asdf, and if that doesn’t kick, search yourself some more synchronous support channel, like the elixir discord.

Maybe even ask for a 1:1 mentoring session there.

You need interactive, synchronous support in this matter, without hour long delays, waiting for the next reply.

What about looking up my computers manual could that help at all and where would I start by looking up information on asdf

Could it be at all possible to fix this problem by not erasing my os system but to erase and reinstall erlang and Elixir all over again?

Even if there was a manual with your computer, it wouldn’t cover asdf.

Asdf is a “niche” software, used by developers on Linux and Mac to be able to have different versions of language runtimes for their various projects.

With regular Linux package managers that’s not easy.

And for asdf I already linked the “manual”, it’s website, in my previous post.

1 Like