Mix phx.new deps error - cowlib - the dependency does not match the requirement

I’m seeing an error when I try to run iex -S mix phx.server after a fresh mix phx.new:

○ iex -S mix phx.server
Erlang/OTP 21 [erts-10.2.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Unchecked dependencies for environment dev:
* cowlib (Hex package)
  the dependency does not match the requirement "~> 2.7.2", got "2.7.0"
** (Mix) Can't continue due to errors on dependencies

I checked the dependencies, and from what I can tell, it seems like cowlib 2.7.2 is installed (not 2.7.0).

Any help?

2 Likes

Looks like the .hex file shows cowlib as 2.7.2, but ebin/cowlib.app shows cowlib as vsn 2.7.0.

Definitely looks like a bug, I’m able to reproduce it as well. I thought clearing and rebuilding the deps would help but it did not.

It looks like a bug in cowlib/cowboy to me. Maybe 2.7.1 and 2.7.2 actually use the build number 2.7.0?

Adding {:cowlib, "2.7.0"} to your list of deps should work around the issue (you may also need to run mix deps.unlock cowboy).

Looks like there’s already an issue and PR filed:

2 Likes

I’m new to Elixir + Phoenix and am running into this issue. Any idea how to get around this after running mix ecto.create? Not sure what dependency file to change.

Setting {:cowlib, "~> 2.7.0", override: true} worked for me

3 Likes

You need to modify the deps function of your mix.exs file.

1 Like

alternate is downgrade cowboy to 2.6.1, in mix.exs

  defp deps do
    [
      {:cowboy, "2.6.1"},
      {:phoenix, "~> 1.4.0"},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"}
    ]
  end
2 Likes

As a workaround you can add cowlib 2.7.0 to your deps.

defp deps do
  [
    {:phoenix, "~> 1.4.3"},
    {:phoenix_pubsub, "~> 1.1"},
    {:phoenix_ecto, "~> 4.0"},
    {:ecto_sql, "~> 3.0"},
    {:postgrex, ">= 0.0.0"},
    {:gettext, "~> 0.11"},
    {:jason, "~> 1.0"},
    {:plug_cowboy, "~> 2.0"},
    {:cowlib, "2.7.0"}
  ]
end
1 Like

Same here. This is a bug

This works. But the underlying problem needs to be resolved.

this works

Looks like this has been fixed: https://github.com/ninenines/cowlib/issues/77#issuecomment-480200997

2 Likes

Yup, 2.7.3 is out and I recommend folks to migrate to it as it has an important bug fix on top of 2.7.0.

3 Likes

This is still failing with cowboy 2.6.3 and cowlib 2.7.3

It’s working for me right now. Can you check if you’re on the latest version of the phx.new task? It should look like this:

$ mix phx.new -v
Phoenix v1.4.6

If you’re on an older version can you retry again on the latest after running mix archive.install hex phx_new 1.4.6 (from https://hexdocs.pm/phoenix/installation.html)

I am using Erlang/OTP 21
Elixir 1.8.2
Phoenix v1.4.6
and ubuntu 16.04

I tried on mac with the same versions and there is working.