Phoenix: (RuntimeError) plug_cowboy dependency missing after mix phx.new

Created on 23 Oct 2018  路  10Comments  路  Source: phoenixframework/phoenix

This issue is just a dependency warning, but looks nasty and breaks what a new user sees in the docs. If you're someone with this error, its safe to follow the instructions and add plug_cowboy to your mix.exs file.

  • Elixir version (elixir -v): 1.7
  • Phoenix version (mix deps): 1.3.4
  • Operating system: MacOS

Expected behavior

After running mix phx.new my_new_project followed by mix phx.server the server should start successfully in dev environment

Actual behavior

Mix shows a dependency warning (in nasty red text):

** (Mix) Could not start application nikita: Nikita.Application.start(:normal, []) returned an error: shutdown: failed to start child: NikitaWeb.Endpoint ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Handler ** (EXIT) an exception was raised: ** (RuntimeError) plug_cowboy dependency missing (plug) lib/plug/adapters/cowboy.ex:54: Plug.Adapters.Cowboy.warn_and_raise/0 (plug) lib/plug/adapters/cowboy.ex:29: Plug.Adapters.Cowboy.child_spec/4

phoenix depends on plug
plug released a new version outsourcing the cowboy adapter to plug_cowboy
now as phoenix鈥檚 dependency on plug is not restrictive enough you get that new version of plug, which no longer fit鈥檚 with the code the phoenix generators generate

open for guidance

Most helpful comment

For Phoenix 1.3 users, replace the {:cowboy, "~> 1.0"} dependency with {:plug_cowboy, "~> 1.0"} in your project鈥檚 mix.exs.

def deps do
  [
    {:plug_cowboy, "~> 1.0"},
  ]
end

All 10 comments

@JediLuke 1.4.0-rc.2 uses the correct plug deps, I suspect you are not using the latest one; could you double-check?

Edit: oops, I see you didn't meant to use RC. I guess in any way this issue will be fixed when 1.4 is out for new apps.

Any updates on the release date for 1.4?
Thanks!

For Phoenix 1.3 users, replace the {:cowboy, "~> 1.0"} dependency with {:plug_cowboy, "~> 1.0"} in your project鈥檚 mix.exs.

def deps do
  [
    {:plug_cowboy, "~> 1.0"},
  ]
end

I'am not sure if it makes sense to to add a fix for this or to wait for 1.4 release? The error message returned seems explanatory enough so I don't think there will be too many hurdles for people new to phoenix (like myself :))

Just encountered this and would say this is definitely bad experience for someone new to Phoenix: you hear all the great things about Elixir, install latest stable phoenix, follow all the guidance and expect all to work out of the box, but instead get to this issue. I think this is absolutely fine and easy to fix in RC/master/whatever but should not happen in stable 1.3.4

Actually arrived here, because dependabot bumped our phoenix_ecto version which also bumped our plug version. Caused our release to fail :(
The message was clear, but it was still unexpected, since our CI doesnt actually RUN mix phx.server

I thought this elixir/phoenix ecosystem is better than others.This is disappointing.

If you're new to Phoenix (like myself), after editing mix.exs like @jayjun mentioned, run mix deps.get after editing to finish installing the dependencies.

I came across this today as I was updating to the latest v1.3, leaving the update to v1.4 for another time. As others have said it was easy enough to fix with the information given, but I would have thought this should be fixed in the v1.3 branch.

Am I right in thinking the fix is merely changing :cowboy to :plug_cowby (keeping "~> 1.0") to these lines? https://github.com/phoenixframework/phoenix/blob/1213d054e184c8e018ad78445c42f349e3d406ed/installer/test/phx_new_umbrella_test.exs#L139 https://github.com/phoenixframework/phoenix/blob/d133263139c32f0d436be4849aca8429d1e80b0a/installer/templates/new/mix.exs#L47

If so, should I submit a pull request to the v1.3 branch from a topic branch? Thanks.

@DavidOliver As I understand it (which may be totally wrong), plug >= 1.7.0 has an implicit dependency on plug_cowboy >= 2.0 (unless you use a different web server of course), and plug_cowboy 2.0 has a dependency on cowboy 2.0, and Phoenix 1.3 does not work with cowboy 2.0. So I would expect that Phoenix 1.3 would not work with plug_cowboy 1.0 but I haven't tested this.

Was this page helpful?
0 / 5 - 0 ratings