Can't compile "cowboy" in a bare new phoenix project

Elixir / OTP version:

$ elixir -v
Erlang/OTP 21 [erts-10.0] [source] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.10.3 (compiled with Erlang/OTP 21)

Phoenix version:

$ mix --version
Phoenix v1.5.0

Trying to create a database (after mix name --no-webpack):

$ mix ecto.create
===> Compiling cowboy
Function: request_process/3
===> Compiling src/cowboy_stream_h.erl failed
src/cowboy_stream_h.erl:none: internal error in sys_core_dsetel;
crash reason: {case_clause,
             #{0 => 1,1 => 1,2 => 1,4 => 1,5 => 1,6 => 1,10 => 0,
               'Reason' => 1}},

  in function  compile:'-select_passes/2-anonymous-2-'/3 (compile.erl, line 585)
  in call from compile:'-internal_comp/5-anonymous-1-'/3 (compile.erl, line 349)
  in call from compile:fold_comp/4 (compile.erl, line 376)
  in call from compile:internal_comp/5 (compile.erl, line 360)
  in call from compile:'-do_compile/2-anonymous-0-'/2 (compile.erl, line 177)
  in call from compile:'-do_compile/2-anonymous-1-'/1 (compile.erl, line 190)

** (Mix) Could not compile dependency :cowboy, "/home/henrique/.asdf/installs/elixir/1.10.3-otp-21/.mix/rebar3 bare compile --paths="/home/henrique/Desktop/Project
s/materic/materic_demo/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile cowboy", update it with "mix deps.update co
wboy" or clean it with "mix deps.clean cowboy"

When i execute the command with rebar:

$ /home/henrique/.asdf/installs/elixir/1.10.3-otp-21/.mix/rebar3 bare compile --paths="/home/henrique/Desktop/Projects/materic/demo/_build/dev/lib/*/ebin"
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> When submitting a bug report, please include the output of `rebar3 report "your command"`

With DEBUG=1:

$ DEBUG=1 /home/henrique/.asdf/installs/elixir/1.10.3-otp-21/.mix/rebar3 bare compile --
===> Expanded command sequence to be run: []
===> Provider: {default,do}
===> Expanded command sequence to be run: [{default,app_discovery},
===> Provider: {default,app_discovery}
===> Provider: {bare,compile}
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: {badmatch,[]}
===> Stack trace to the error location:
===> When submitting a bug report, please include the output of `rebar3 report "your command"`

Some interesting things:

  • I also tried mix local.rebar --force and mix local.rebar and got the same error.
  • It creates the database in other existent phoenix projects in the same machine using mix ecto.create.
  • I also tried to remove / purge and reinstall both Erlang, Elixir and Phoenix.
  • I also tried to install others phx_new versions / archives.
  • The OS is an Ubuntu 16 / 32bits.
  • It happened “out of the blue”.
  • Of course other mix tasks aren’t working. But only in new phoenix projects.

Do you still get the error if you use the 1.5.3 version of (mix archive.install hex phx_new 1.5.3)?

What version of cowboy is being used (mix deps)? I don’t think cowboy 2.8 is supported yet.

Do you still get the error with a plain mix compile?

1 Like

Cowboy 2.8.0 was released yesterday on and requires OTP22+.

Two possible solutions:

  • upgrade to OTP22
  • set Cowboy version in mix.exs (something like {:cowboy, "< 2.8.0", override: true} in the deps section but haven’t tested)

Thank you @axelson @tangui

cowboy 2.8 is not supported in this OTP version


1 Like

Should this be address in phoenix? It seems like phoenix should protect itself from another dependency pulling in an incompatible version of cowboy (2.8.0).

This would save us from having to explicitly declare the correct cowboy version in our mix.exs file. When we really don’t care about what version of cowboy we are using.

I ran into the same issue when running a mix deps.update new_relic_agent resulted in new_relic_agent 1.18.0 => 1.18.4 which caused my cowboy to be updated from 2.6.3 to 2.8.0, cowboy 2.8.0 is pulling in cowlib 2.9.1 which is the actual root of the issue, because cowlib 2.9.1 will not compile with phoenix.

Or is this a cowboy issue that 2.8.0 should have been a major bump?

Also, I would argue that the correct fix for this, at least in my situation would be to add

{:cowlib, "~> 2.8.0"}

to deps in your mix.exs file. This is the bare minimum requirement


saved my life!

1 Like

Works for me.