初めに
某会社さんでElixirを始めて触った時に、WSL上のElixirでライブラリをインストールするときにエラーが発生したのでその解決策をメモ
もう一つ、WSL上でElixirを動かすときにモニタリングツールが利用できなかったのでそちらもどうぞ→WSL上でElixirを使うときにモニタリングツールが起動できなかった件
環境
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
問題
WSLのUbuntu環境にて、ライブラリを組み込む際に以下のようなエラーが出た
$ mix deps.get
23:33:01.754 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: '/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1' not found (required by /usr/lib/erlang/lib/crypto-4.5.1/priv/lib/crypto.so)'"
OpenSSL might not be installed on this system.
23:33:01.884 [warn] The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library: \'/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1\' not found (required by /usr/lib/erlang/lib/crypto-4.5.1/priv/lib/crypto.so)\''}}
** (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: 658]}, {:tls_record, :supported_protocol_versions, 0, [file: 'tls_record.erl', line: 344]}, {:ssl, :handle_options, 3, [file: 'ssl.erl', line: 1504]}, {:ssl, :connect, 4, [file: 'ssl.erl', line: 522]}, {:http_transport, :connect, 4, [file: 'http_transport.erl', line: 109]}, {:httpc_handler, :connect, 4, [file: 'httpc_handler.erl', line: 786]}, {:httpc_handler, :connect_and_send_first_request, 3, [file: 'httpc_handler.erl', line: 812]}]}}}]}
Could not install Hex because Mix could not download metadata at https://repo.hex.pm/installs/hex-1.x.csv.
解決
以下のコマンドを実行
sudo apt-get install aptitude
sudo aptitude install erlang-crypto
erlang-crypto
のインストール中画面が変わって色々聞かれるが、OK→Yes
改めてmix deps.get
をする
Hexをインストールしていない場合、Hexをインストールするか?と聞かれるのでYでインストール
$ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
New:
poison 4.0.1
* Getting poison (Hex package)
これで解決しました!