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 phx.new --version
Phoenix v1.5.0

Trying to create a database (after mix phx.new 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,
    {'EXIT',
        {{case_clause,
             #{0 => 1,1 => 1,2 => 1,4 => 1,5 => 1,6 => 1,10 => 0,
               'Reason' => 1}},
         [{sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,98}]},
          {lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]},
          {lists,mapfoldl,3,[{file,"lists.erl"},{line,1355}]},
          {sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,188}]},
          {lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]},
          {lists,mapfoldl,3,[{file,"lists.erl"},{line,1355}]},
          {sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,188}]},
          {sys_core_dsetel,visit,2,
              [{file,"sys_core_dsetel.erl"},{line,144}]}]}}}

  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 --
paths="/home/henrique/Desktop/Projects/materic/demo/_build/dev/lib/*/ebin"
===> Expanded command sequence to be run: []
===> Provider: {default,do}
===> Expanded command sequence to be run: [{default,app_discovery},
                                                  {bare,compile}]
===> 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:
[{rebar_prv_bare_compile,do,1,
                         [{file,"/tmp/cirrus-ci-build/src/rebar_prv_bare_compile.erl"},
                          {line,60}]},
 {rebar_core,do,2,
             [{file,"/tmp/cirrus-ci-build/src/rebar_core.erl"},{line,154}]},
 {rebar_prv_do,do_task,5,
               [{file,"/tmp/cirrus-ci-build/src/rebar_prv_do.erl"},{line,87}]},
 {rebar_core,do,2,
             [{file,"/tmp/cirrus-ci-build/src/rebar_core.erl"},{line,154}]},
 {rebar3,run_aux,2,[{file,"/tmp/cirrus-ci-build/src/rebar3.erl"},{line,182}]},
 {rebar3,main,1,[{file,"/tmp/cirrus-ci-build/src/rebar3.erl"},{line,66}]},
 {escript,run,2,[{file,"escript.erl"},{line,758}]},
 {escript,start,1,[{file,"escript.erl"},{line,277}]}]
===> 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 phx.new (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 hex.pm 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)
11 Likes

Thank you @axelson @tangui

cowboy 2.8 is not supported in this OTP version

:grinning:

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

4 Likes

saved my life!

1 Like

Works for me.