Unable to create new Phoenix project - compilation error in file lib/swoosh/adapters/xml/helpers.ex

When trying to start the server on a brand new hello-world app creation and install of Elixir

mix phx.server

I get the following error

===> Compiling cowboy_telemetry                                                                  
==> plug_cowboy                                                                                  
Compiling 5 files (.ex)                                                                          
Generated plug_cowboy app                                                                                                                                                                         
==> swoosh                                                                                                                                                                                        
Compiling 42 files (.ex)  

== Compilation error in file lib/swoosh/adapters/xml/helpers.ex ==
** (ArgumentError) lib file xmerl/include/xmerl.hrl could not be found
    (elixir 1.14.3) lib/record/extractor.ex:41: Record.Extractor.from_lib_file/1
    (elixir 1.14.3) lib/record/extractor.ex:18: Record.Extractor.from_or_from_lib_file/1
    (elixir 1.14.3) lib/record/extractor.ex:5: Record.Extractor.extract/2
    lib/swoosh/adapters/xml/helpers.ex:5: (module)
could not compile dependency :swoosh, "mix compile" failed. Errors may have been logged above. 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"

Version Info

➜  hello_world elixir --version
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit] [smp:32:16] [ds:32:16:10] [async-threads:1] [jit:ns]

Elixir 1.14.3 (compiled with Erlang/OTP 25)

Any ideas to what I might have done wrong?

Hi @chrisolsen can you copy and paste your mix.exs file here?

Hello Chris.
I ran into something possibly similar a few days ago. I installed Elixir on a Debian system and I had to install the package “erlang-xmerl” in addition to make it work.

Just in case this is the same issue for you, I also installed two more packages until it worked: erlang-dev, erlang-dialyzer.

Hmmm, the Debian packaging makes some… interesting choices. The Elixir package depends on a handful of erlang-* packages but NOT the top-level “dummy” package for Erlang, so installing Elixir from nothing will only pull in parts of the full system.

Consider installing the whole Erlang distribution with your package manager before installing Elixir to avoid missing files like this.

2 Likes

Installing erlang is what did the trick!

Thanks for the help everyone :grinning:

In my case, needed to add :xmerl to the extra_applications in mix.exs.