Problems with Elixir (erlang crypto module) on Ubuntu (ARM)

Hey,

I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the Elixir website and installed Elixir 1.6.

pi@NanoPi-M3:~$ elixir -v
Erlang/OTP 20 [erts-9.1.5] [source] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.6.1 (compiled with OTP 19)

Now when I try to install Hex I get:

pi@NanoPi-M3:~$ mix local.hex

18:04:10.362 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library /usr/lib/erlang/lib/crypto-4.1/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.


18:04:10.372 [warn]  The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library /usr/lib/erlang/lib/crypto-4.1/priv/lib/crypto: \'libcrypto.so.1.1: cannot open shared object file: No such file or directory\''}}

** (Mix) httpc request failed with: {:failed_connect, [{:to_address, {'repo.hex.pm', 443}}, {:inet, [:inet], {:eoptions, {:undef, [{:crypto, :supports, [], []}, {:tls_record, :supported_protocol_versions, 1, [file: 'tls_record.erl', line: 407]}, {:tls_record, :supported_protocol_versions, 0, [file: 'tls_record.erl', line: 247]}, {:ssl, :handle_options, 3, [file: 'ssl.erl', line: 709]}, {:ssl, :connect, 4, [file: 'ssl.erl', line: 115]}, {:http_transport, :connect, 4, [file: 'http_transport.erl', line: 109]}, {:httpc_handler, :connect, 4, [file: 'httpc_handler.erl', line: 790]}, {:httpc_handler, :connect_and_send_first_request, 3, [file: 'httpc_handler.erl', line: 802]}]}}}]}

Could not install Hex because Mix could not download metadata at https://repo.hex.pm/installs/hex-1.x.csv.

I then tried to install erlang-crypto but it fails due to missing libssl1.1.0.

pi@NanoPi-M3:~$ sudo apt-get install erlang-crypto
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 erlang-crypto : Depends: libssl1.1 (>= 1.1.0) but it is not installable
E: Unable to correct problems, you have held broken packages.

Then I compiled OpenSSL 1.1.0 from source.

pi@NanoPi-M3:~$ openssl version
OpenSSL 1.1.0f  25 May 2017

But I get the same error when I try to install erlang-crypto.

Now I am at the point where I want to throw the NanoPi-M3 into a corner of my room. It’s really frustrating that it seems to be impossible to get anything working on an ARM based machine.

1 Like

maybe give asdf a try - I have used that on arm64 servers…

I considered it earlier but was unsure if it’ll work on ARM based systems at all.

aptitude is better about unmet dependencies. You can give it a try

sudo apt-get install aptitude
sudo aptitude install erlang-crypto
1 Like

Of course you do, apt isn’t aware of the source compiled openssl.

When you try to install libssl manually what message do you get then?

It should be available in the Ubuntu arm repositories…

I used @dokuzbir s solution and it worked. But it seems like it swapped the esl-erlang package with the erlang-* packages. I think I gonna do a clean install with asdf later.

1 Like

I have the same problem but while running a docker-compose run --rm myapp migrate command. Ubuntu 18.04. It fails on this line in my release_tasks.ex:

Ecto.Migrator.run(repo, migrations_path, :up, all: true)

The deployment and migration succeeded many times before so I have no idea why this happened all of a sudden. I even reverted to the last successful deployment and the issue still appeared. I tried @dokuzbir suggestion and it made no difference. I also updated to all the security and os updates. I don’t think I can use asdf because that would obviate the use of Docker. Any suggestions?

here is the pertinent part of the log:

Running migrations for db
17:16:43.739 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /app/lib/crypto-4.4/priv/lib/crypto.so)'"
OpenSSL might not be installed on this system.

17:16:43.752 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /app/lib/crypto-4.4/priv/lib/crypto.so)'"
OpenSSL might not be installed on this system.

17:16:43.761 [warn] The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library: \'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /app/lib/crypto-4.4/priv/lib/crypto.so)\''}}

17:16:43.774 [error] GenServer #PID<0.145.0> terminating
** (RuntimeError) connect raised UndefinedFunctionError exception.The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true if you wish to see all of the details
    (crypto) :crypto.hash/2
    (postgrex) lib/postgrex/protocol.ex:721: Postgrex.Protocol.auth_md5/4
    (postgrex) lib/postgrex/protocol.ex:576: Postgrex.Protocol.handshake/2
    (db_connection) lib/db_connection/connection.ex:66: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
17:16:43.786 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /app/lib/crypto-4.4/priv/lib/crypto.so)'"
OpenSSL might not be installed on this system.

sudo apt-get install erlang-crypto

what kind of error you get when you try install ?

while running as root:

root@****:~/api.faithfulword.app/add-1.2-api# apt-get install erlang-crypto
Reading package lists... Done
Building dependency tree       
Reading state information... Done
erlang-crypto is already the newest version (1:20.2.2+dfsg-1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

And how about OpenSSL ? Can you check version of it ?

root@****:~/api.faithfulword.app/add-1.2-api# openssl version
OpenSSL 1.1.0g  2 Nov 2017

I am not familiar with folder structure. But only difference i see topic owner’s file location inside erlang
/usr/lib/erlang/lib/crypto-4.1/priv/lib/crypto. A dirty solution maybe copy paste trick can solve.

Yeah I think that is a good direction to follow. I will dig into it further, thanks.

I’m not sure if I can actually copy the file over.

I found it on the host ubuntu OS: /usr/lib/erlang/lib/crypto-4.2/priv/lib/crypto.so (note the different version number, 4.2 instead of 4.4) but in order to get to the /app dir on the docker image, the container has to boot first. Since it can’t boot, I can’t copy the file to the image to see if that will fix the issue.

The issue was that the alpine linux release build was at 3.8, which was at an older version of libssl. The solution was to use alpine linux version 3.9 and apk libssl1.1

4 Likes

Wanted to share my findings as well … I’m trying to go through the distillery docker tutorial, and it seems the installed library is libcrypto.so.1.1 but the error from running the release is searching for libcrypto.so.1.0.0. Yet to figure out how to resolve it, but at least the issue is clear.

Sure enough, after further investigation, I had updated the executing alpine image to 3.9, but forgot to update the elixir image from 1.7.2 to 1.8.1 :man_facepalming: … As the tutorial suggests, Alpine versions from the Erlang image and executing image must match.

1 Like

I am running into a similar issue when trying to run this command for my elixir umbrella project:

docker run --rm -ti \
             -p 4000:4000 \
             -e COOKIE=a_cookie \
             -e BASIC_AUTH_USERNAME=UserName \
             -e BASIC_AUTH_PASSWORD=Password \
             -e BASIC_AUTH_REALM=realm  political_project:0.1.0

the error is:

args: [load_failed,"Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /political_project/lib/crypto-4.4/priv/lib/crypto.so)'","OpenSSL might not be installed on this system.\n"]
    format: "Unable to load crypto library. Failed with error:~n\"~p, ~s\"~n~s"
    label: {error_logger,error_msg} # [...]

I am trying to use Docker for my project using this tutorial

How can I solve this ?

Have you tried building from source? Here are my notes of building from source in a Begalbone, obviously with ARM chip.

1 Like

thank you @micahrye ! I simply forgot to run docker build -t myproject after I changed the version. It works now ! :blush: