Reputation: 4837
I'm trying to generate an Erlang Cowboy release by scrupulously following (e.g. cut-and-paste) the Getting Started instructions at:
https://github.com/extend/cowboy/blob/master/guide/getting_started.md
All goes well until I create Makefile
and execute$ make
. The compile process terminates as follows:
...
make[1]: Leaving directory `/home/lloyd/hello_erlang/deps/cowboy'
ERLC hello_erlang_app.erl hello_handler.erl hello_erlang_sup.erl
compile: warnings being treated as errors
src/hello_handler.erl:3: behaviour cowboy_http_handler undefined
make: *** [ebin/hello_erlang.app] Error 1
I've triple checked my code but can't see anything I've missed.
So, is this my error? Or a bug in the Getting Started instructions or in Cowboy itself? If it's my mistake, how can I fix?
I've posed this question to [email protected]
, but so far no response.
Upvotes: 0
Views: 1236
Reputation: 20916
The cause of the problem is twofold:
-behaviour(cowboy_http_handler).
. This is perfectly correct.cowboy_http_handler
module in its search pathThis causes the error as the behaviour declaration tells the compiler to go out and find that module and find out which callback functions the behaviour expects. Normally if the compiler can't find the behaviour module, or if it can find and there are some callbacks missing then it issues a warning about this and just continues. However your Makefile sets a compiler option which treats all warnings as errors so the compilation fails.
There are (at least) three solutions to this:
-pa Dir
option for the cowboy beam file directory so it can find the file.$ERL_LIBS
.Note that even if the compiler finds the right module you still have to make sure that when you run the system Erlang can find the directory. There is no automatic equivalence between the compile-time and run-time environments.
Upvotes: 5