Runtime error while compiling Phoenix: "error parsing file ".../OTP-PUB-KEY.hrl, got: {:error, :enoent}"

I truncated the error message in the title to save space. The full error message is below:

==> phoenix
Compiling 67 files (.ex)

== Compilation error in file lib/mix/tasks/phx.gen.cert.ex ==
** (RuntimeError) error parsing file /usr/lib/erlang/lib/public_key-1.6.7/include/OTP-PUB-KEY.hrl, got: {:error, :enoent}
    (elixir) lib/record/extractor.ex:84: Record.Extractor.read_file/2
    (elixir) lib/record/extractor.ex:50: Record.Extractor.extract_record/2
    lib/mix/tasks/phx.gen.cert.ex:146: (module)
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
could not compile dependency :phoenix, "mix compile" failed. You can recompile this dependency with "mix deps.compile phoenix", update it with "mix deps.update phoenix" or clean it with "mix deps.clean phoenix"

I’m new to Elixir/Phoenix but I know that :enoent means that the file couldn’t be found. Correct me if I’m wrong but it seems like the OTP-PUB-KEY.hrl file from my erlang library is missing…? I tried searching for information on that file (looks like an RSA public key) but I couldn’t find much that seemed to help with this issue. Any help/suggestions would be really appreciated.

What is your erlang version? This is strange because in my 21.3.8 otp the public_key has a 1.6.6 version. Also ls /usr/lib/erlang/lib/ might help

1 Like

I’m running Erlang/OTP 22:

Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
1 Like

ls /usr/lib/erlang/lib/ ?

How did you install erlang?

1 Like

Here’s what I get when I run ls /usr/lib/erlang/lib/:

total 80K
drwxr-xr-x 20 root root 4.0K May 21 13:06 .
drwxr-xr-x  6 root root 4.0K May 18 13:08 ..
drwxr-xr-x  4 root root 4.0K May 18 13:08 asn1-5.0.9
drwxr-xr-x  3 root root 4.0K May 18 13:08 compiler-7.4
drwxr-xr-x  4 root root 4.0K May 18 13:08 crypto-4.5
drwxr-xr-x  3 root root 4.0K May 18 13:08 erl_interface-3.12
drwxr-xr-x  3 root root 4.0K May 18 13:08 erts-10.4
drwxr-xr-x  4 root root 4.0K May 10 13:40 ftp-1.0.2
drwxr-xr-x  3 root root 4.0K May 18 13:08 hipe-3.19
drwxr-xr-x  5 root root 4.0K May 18 13:08 inets-7.0.8
drwxr-xr-x  4 root root 4.0K May 18 13:08 kernel-6.4
drwxr-xr-x  3 root root 4.0K May 18 13:08 mnesia-4.16
drwxr-xr-x  3 root root 4.0K May 18 13:08 public_key-1.6.7
drwxr-xr-x  5 root root 4.0K May 18 13:08 runtime_tools-1.13.3
drwxr-xr-x  4 root root 4.0K May 18 13:08 sasl-3.4
drwxr-xr-x  3 root root 4.0K May 21 13:06 ssl-9.3.1
drwxr-xr-x  4 root root 4.0K May 18 13:08 stdlib-3.9
drwxr-xr-x  4 root root 4.0K May 18 13:08 syntax_tools-2.2
drwxr-xr-x  4 root root 4.0K May 10 13:40 tftp-1.0.1
drwxr-xr-x  6 root root 4.0K May 18 13:08 tools-3.2

I installed Erlang via the Ubuntu Elixir 1.8.2 package from the Erlang website (which included Erlang 22 as well).

Just in case:

ls /usr/lib/erlang/lib/public_key-1.6.7/include/

May be you have no read rights from this file?

That might be the case:

ls: cannot access '/usr/lib/erlang/lib/public_key-1.6.7/include/': No such file or directory

If that is the issue, is there a way to grant myself read rights?

)) Just one last try:

ls /usr/lib/erlang/lib/public_key-1.6.7/

That got us something:

total 12K
drwxr-xr-x  3 root root 4.0K May 18 13:08 .
drwxr-xr-x 20 root root 4.0K May 21 13:06 ..
drwxr-xr-x  2 root root 4.0K May 21 13:06 ebin

It’s got just the one directory, ebin:

total 852K
drwxr-xr-x 2 root root 4.0K May 21 13:06 .
drwxr-xr-x 3 root root 4.0K May 18 13:08 ..
-rw-r--r-- 1 root root 491K May 20 15:09 OTP-PUB-KEY.beam
-rw-r--r-- 1 root root  71K May 20 15:09 PKCS-FRAME.beam
-rw-r--r-- 1 root root  51K May 20 15:09 pubkey_cert.beam
-rw-r--r-- 1 root root  23K May 20 15:09 pubkey_cert_records.beam
-rw-r--r-- 1 root root  32K May 20 15:09 pubkey_crl.beam
-rw-r--r-- 1 root root  20K May 20 15:09 pubkey_pbe.beam
-rw-r--r-- 1 root root  18K May 20 15:09 pubkey_pem.beam
-rw-r--r-- 1 root root  54K May 20 15:09 pubkey_ssh.beam
-rw-r--r-- 1 root root  472 May 20 15:09 public_key.app
-rw-r--r-- 1 root root  791 May 20 15:09 public_key.appup
-rw-r--r-- 1 root root  66K May 20 15:09 public_key.beam

So certainly not the include directory that the compiler seems to be looking for and the public key is a .beam file.

Looks like you have invalid/incomplete installation

I recomment you two options:

  1. Reinstall erlang

  2. Use asdf with asdf-erlang and asdf-elixir which allows you to have different versions of erlang and elixir for different projects

Personally I prefer an asdf

2 Likes

Reinstalling did the trick. Thanks for the help!

3 Likes

On a fresh debian bullseye install , sudo apt install erlang-dev did the trick

3 Likes

On a fresh ubuntu install, there was a public_key-1.13 but no public_key-1.6.7. I created a symlink, and so far it works…