elixir-plug / plug_cowboy

Plug adapter for the Cowboy web server
Other
236 stars 47 forks source link

Many errors, during compile. Elixir releases are unusable? #101

Open c4lliope opened 2 weeks ago

c4lliope commented 2 weeks ago
> mix deps.compile
# ...
===> Compiling cowboy
src/cowboy_clear.erl:16:2: Warning: behaviour ranch_protocol undefined

src/cowboy_tls.erl:16:2: Warning: behaviour ranch_protocol undefined

===> Compiling src/cowboy_http.erl failed
src/cowboy_http.erl:{155,14}: can't find include lib "cowlib/include/cow_inline.hrl"; Make sure cowlib is in your app file's 'applications' list
src/cowboy_http.erl:{156,14}: can't find include lib "cowlib/include/cow_parse.hrl"; Make sure cowlib is in your app file's 'applications' list
src/cowboy_http.erl:512:11: undefined macro 'IS_TOKEN/1'
src/cowboy_http.erl:658:74: undefined macro 'IS_WS/1'

src/cowboy_http.erl:492:6: function parse_method/4 undefined
src/cowboy_http.erl:646:4: function parse_hd_name/4 undefined

src/cowboy_http.erl:517:1: Warning: function parse_uri/3 is unused
src/cowboy_http.erl:534:1: Warning: function parse_uri_authority/3 is unused
src/cowboy_http.erl:538:1: Warning: function parse_uri_authority/5 is unused
src/cowboy_http.erl:563:1: Warning: function parse_uri_path/5 is unused
src/cowboy_http.erl:573:1: Warning: function parse_uri_query/6 is unused
src/cowboy_http.erl:582:1: Warning: function skip_uri_fragment/6 is unused

Seems like calling up an "app file's 'applications' list" means I should be using: https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html#child_spec/1 inside lib/<app>/application.ex -

defmodule Pain do
  def start(_type, _args) do
    children = [
      # Start the Telemetry supervisor
      PainWeb.Telemetry,
      # Start the Ecto repository
      # Pain.Repo,
      # Start the PubSub system
      {Phoenix.PubSub, name: Pain.PubSub},
      # Start Finch
      {Finch, name: Pain.Finch},
      # Start the Endpoint (http/https)
      { Plug.Cowboy, scheme: :http, plug: PainWeb.Endpoint },
      PainWeb.Endpoint,
      # Start a worker by calling: Pain.Worker.start_link(arg)
      # {Pain.Worker, arg}
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Pain.Supervisor]
    Supervisor.start_link(children, opts)
  end
  # ...
end

And here's config:

# config/config.exs
config :pain, PainWeb.Endpoint,
  url: [host: System.get_env("PHX_HOST") || "0.0.0.0"],
  adapter: Phoenix.Endpoint.Cowboy2Adapter,
  render_errors: [
    formats: [html: PainWeb.ErrorHTML, json: PainWeb.ErrorJSON],
    layout: false,
  ],
  pubsub_server: Pain.PubSub,
  live_view: [signing_salt: "aaaabbbb"]
# ...
# config/prod.exs
import Config
config :pain, PainWeb.Endpoint,
  server: true,
  http: [ ip: {0, 0, 0, 0}, port: System.get_env("PORT") ],
  cache_static_manifest: "priv/static/cache_manifest.json"
# ...
josevalim commented 2 weeks ago

What is your Erlang, Elixir, and OS versions? Do you have a small app that reproduces the error? There are many people relying on Elixir releases everyday, so it is unlikely they are unusable, but rather something more specific going on.