Issue with compiling swoosh in production environment

while deploying an Elixir/Phoenix app to AWS EC2 instance

I am trying to compile my Phoenix project in the production environment by running the sudo MIX_ENV=prod mix compile command, but I am running into an error with the swoosh dependency. Specifically, I am getting a runtime error while compiling swoosh that says:

 sudo mix deps.compile swoosh
==> swoosh
Compiling 42 files (.ex)

== Compilation error in file lib/swoosh/adapters/xml/helpers.ex ==
** (RuntimeError) error parsing file /usr/lib/erlang/lib/xmerl-1.3.28/include/xmerl.hrl, got: {:error, :enoent}
    (elixir 1.12.2) lib/record/extractor.ex:84: Record.Extractor.read_file/2
    (elixir 1.12.2) lib/record/extractor.ex:50: Record.Extractor.extract_record/2
    lib/swoosh/adapters/xml/helpers.ex:5: (module)
    (stdlib 3.17) erl_eval.erl:685: :erl_eval.do_apply/6
could not compile dependency :swoosh, "mix compile" failed. You can recompile this dependency with "mix deps.compile swoosh", update it with "mix deps.update swoosh" or clean it with "mix deps.clean swoosh"

have tried updating the swoosh dependency by running mix deps.update swoosh and recompiling it by running sudo mix deps.compile swoosh, but the error still persists. I have also tried cleaning my dependencies by running sudo mix deps.clean --all and getting them again by running sudo mix deps.get --only prod, but the issue remains.

Here is my erlang version

 elixir --version
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit]
Elixir 1.12.2 (compiled with Erlang/OTP 24)

Could you please help me resolve this issue? I am running swoosh version 1.9.1 and Phoenix version 1.6.16 in my project. Any help or suggestions would be greatly appreciated.

Seems to be a similar issue reported here.

Try installing your OS’ erlang-xmerl package.

@adamu Thanks