ninenines/cowboy

2.10 Getting Started: Makefile issue -- No rule to make target 'run'

7stud opened this issue · 2 comments

macOS 12.5.1

----


% erl
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
1> 

----

% gmake --version
GNU Make 4.4.1
Built for aarch64-apple-darwin21.6.0
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

The Getting Started guide says:

Cowboy setup

We will modify the Makefile to tell the build system it needs to fetch and compile Cowboy:

PROJECT = hello_erlang

DEPS = cowboy
dep_cowboy_commit = 2.10.0

DEP_PLUGINS = cowboy

include erlang.mk

The DEP_PLUGINS line tells the build system to load the plugins Cowboy provides. These include predefined templates that we will use soon.

If you do make run now, Cowboy will be included in the release and started automatically. This is not enough however, as Cowboy doesn't do anything by default. We still need to tell Cowboy to listen for connections.

However, when I execute make run, this is the output I get:

erlang_programs/cowboy_stuff/hello_erlang% gmake run
gmake: *** No rule to make target 'run'.  Stop.

If I use the following Makefile:

PROJECT = hello_erlang
PROJECT_DESCRIPTION = New project
PROJECT_VERSION = 0.1.0

DEPS = cowboy
dep_cowboy_commit = 2.10.0

DEP_PLUGINS = cowboy

BUILD_DEPS += relx

include erlang.mk

then everything seems to build fine:

erlang_programs/cowboy_stuff/hello_erlang% gmake run
 DEPEND hello_erlang.d
 ERLC   hello_erlang_app.erl hello_erlang_sup.erl
 APP    hello_erlang
erl +A1 -noinput -boot no_dot_erlang -pa ebin/ -pz /Users/7stud/erlang_programs/cowboy_stuff/hello_erlang/.erlang.mk/rebar3/_build/prod/lib/*/ebin/ -eval "	Config = 	(fun() ->		Config0 =			case file:consult(\"/Users/7stud/erlang_programs/cowboy_stuff/hello_erlang/relx.config\") of				{ok, Terms} ->					Terms;				{error, _} ->					[end,		case filelib:is_file(\"/Users/7stud/erlang_programs/cowboy_stuff/hello_erlang/relx.config.script\") of		true ->				Bindings = erl_eval:add_binding('CONFIG', Config0, erl_eval:new_bindings()),			{ok, Config1} = file:script(\"/Users/7stud/erlang_prog

...
...

Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
(hello_erlang@127.0.0.1)1> 

To assemble the working Makefile, I started with the Makefile generated by:

% gmake -f erlang.mk bootstrap bootstrap-rel

and I added the lines shown in the Getting Started guide that were not already in the Makefile:

PROJECT = hello_erlang

DEPS = cowboy
dep_cowboy_commit = 2.10.0

DEP_PLUGINS = cowboy

include erlang.mk

So, maybe the Getting Started guide should say,

Add the following lines to your Makefile:

PROJECT = hello_erlang    
...
...
...

DEPS = cowboy
dep_cowboy_commit = 2.10.0

DEP_PLUGINS = cowboy

include erlang.mk    

Yes relx needs to be added now. I will fix it for 2.11 releasing soon. Thank you!

I have updated the guide locally, it'll be part of 2.11. Closing, thanks!