Installing Elixir on Centos 7 - Mix.Error: Could not decode public key

I am trying to install elixir on our Centos 7 build agents.

I’ve installed erlang 19

$ erl
Erlang/OTP 19 [erts-8.1] [source-77fb4f8] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.1  (abort with ^G)
1>

I’ve pulled the tar for 1.4.2 from github. When I run
make clean test

This is the output I am getting.

  1) test installs public keys (Mix.Tasks.Local.PublicKeysTest)
     test/mix/tasks/local.public_keys_test.exs:31
     ** (Mix.Error) Could not decode public key: /home/tomha/elixir-1.4.2/lib/mix/tmp/sample.pub. The public key contents are shown below.

     -----BEGIN PUBLIC KEY-----
     MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmlRL//AgfszL2vkk7G3K
     t+vrI2d3aG+fGD4BZ1k1Qd/mS0EoDNfDQCpqtLzdM7oOjtu0BNCBvG3HC0tlAU92
     i3EFqEC7RSHNIGYrQ4g5WwGQMw8+Qp3D32esw7iRZKvtJu8IpS7l8x4KQq1QbfTh
     s+3yFOQyytnY6of7w2Rv37WtdA3wKAIP6yPgvl8QzwxHRORX4zNcadsJOuZt3ncv
     Bq7pyQN8g2ddF86Ycep/+cU4/onnGW3zHn5pGdvuiHqxGOq+s3+UzljLyLlTCwzz
     ncYdESIw29EEIB5xTcT0Q4qRQEuDwcp8/fASTZ7c6lv8AfpRKb69tGWLoXcx/V9P
     dQIDAQAB
     -----END PUBLIC KEY-----


     Public keys must be valid and be in the PEM format

     stacktrace:
       (mix) lib/mix.ex:276: Mix.raise/1
       (mix) lib/mix/tasks/local.public_keys.ex:63: Mix.Tasks.Local.PublicKeys.install/2
       test/mix/tasks/local.public_keys_test.exs:36: (test)

....................................................................................................................................................................................................................................

  2) test select correct versions from csv (Mix.LocalTest)
     test/mix/local_test.exs:80
     ** (Mix.Error) Could not decode public key: in-memory public key for Elixir v1.4.2. The public key contents are shown below.

     -----BEGIN PUBLIC KEY-----
     MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAslPz1mAfyAvRv8W8xOdv
     HQMbDJkDKfRhsL4JBGwGH7qw0xh+TbaUlNaM3pF+i8VUjS/4FeXjT/OAUEAHu5Y2
     rBVlx00QcH8Dpbyf+H73XiCs0MXnTSecqDgzx6i6NMi8knklHT7yHySHtuuPmPuN
     Po8QTKolCKftwPE/iNDeyZfwufd+hTCoCQdoTVcB01SElfNtvKRtoKbx35q80IPr
     rOcGsALmr58+bWqCTY/51kFeRxzrPJ5LdcLU/AebyWddD4IUfPDxk16jTiCagMWA
     JPSwo8NUrWDIBbD+rEUp06y0ek276rG5Tzm/3Bma56RN/u6nAqBTBE8F2Hu2QBKj
     lQIDAQAB
     -----END PUBLIC KEY-----


     Public keys must be valid and be in the PEM format

     stacktrace:
       (mix) lib/mix.ex:276: Mix.raise/1
       (mix) lib/mix/public_key.ex:56: anonymous fn/4 in Mix.PublicKey.verify/3
       (elixir) lib/enum.ex:2732: Enum.do_any?/2
       (mix) lib/mix/local.ex:125: Mix.Local.find_matching_versions_from_signed_csv!/2
       test/mix/local_test.exs:86: anonymous fn/0 in Mix.LocalTest.test select correct versions from csv/1
       (elixir) lib/file.ex:1162: File.cd!/2
       test/mix/local_test.exs:81: (test)

..................

Finished in 91.4 seconds (6.0s on load, 85.4s on tests)
405 tests, 2 failures

Randomized with seed 941253
make: *** [test_mix] Error 1
2 Likes

more specific

Installed Packages
erlang.x86_64                                                       19.3-1.el7.centos

It looks like something may be broken with ssl or crypto?

$ mix
Could not find Hex, which is needed to build dependency :loki
Shall I install Hex? (if running non-interactively, use: "mix local.hex --force") [Yn]

22:30:42.441 [info]  Application crypto exited: :stopped
** (MatchError) no match of right hand side value: {:error, {:asn1, {'no such file or directory', 'asn1.app'}}}
    (mix) lib/mix/utils.ex:432: Mix.Utils.read_httpc/1
    (mix) lib/mix/utils.ex:376: Mix.Utils.read_path/2
    (mix) lib/mix/local.ex:139: Mix.Local.read_path!/2
    (mix) lib/mix/local.ex:118: Mix.Local.find_matching_versions_from_signed_csv!/2
    (mix) lib/mix/tasks/local.hex.ex:29: Mix.Tasks.Local.Hex.run/1
    (mix) lib/mix/dep/loader.ex:143: Mix.Dep.Loader.with_scm_and_app/4
    (mix) lib/mix/dep/loader.ex:99: Mix.Dep.Loader.to_dep/3
    (elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
1 Like

You have OpenSSL installed?

Yes :confused:

Installed Packages
openssl.x86_64                                                            1:1.0.1e-60.el7_3.1

Interesting… it seems like yum install erlang-19.3* installs a bad package. If I do yum install esl-erlang-19.3 things are happier.

2 Likes

You should use the erlang solutions erlang install and build elixir from source on CentOS, imho. Try this set of instructions

2 Likes

I’ll try the precompiled :thumbsup:

1 Like

let me know how it goes

I am getting this now with the precompiled version:

$ /opt/elixir/elixir-lang-elixir-e25c371/bin/elixir --version
{"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({undef,[{elixir,start_cli,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...

This message "init terminating in do_boot" occured very often to me, when the files were compiled with a newer erlang version than the one that is currently available.

It may be the Erlang version like @NobbZ is suggesting. Which Erlang and Elixir versions are you using?