我一直在玩 rebar3 (3.15.0) 只是为了让它与基本模板一起运行,并在试图让一个简单的 Hello World 类型示例程序运行时遇到问题。我从模板命令开始构建新版本:
rebar3 new release myfirstproj
.
它在我运行时运行良好,rebar3 shell
但在运行 release 命令时出现以下错误:myfirstproj.cmd console
使用rebar3 release
.
我添加到基本模板中的唯一内容是io:format("Hello world!")
主管中的 .. 似乎下面的undef表明它找不到该myfirstproj_app:start
功能.. 任何想法为什么它在这里不起作用但在 rebar3 shell 中起作用?
OTP 23 [erts-11.0] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:30]
=CRASH REPORT==== 21-Apr-2021::22:39:52.740000 ===
crasher:
initial call: application_master:init/4
pid: <0.85.0>
registered_name: []
exception exit: {bad_return,
{{myfirstproj_app,start,[normal,[]]},
{'EXIT',
{undef,
[{myfirstproj_app,start,[normal,[]],[]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,277}]}]}}}}
in function application_master:init/4 (application_master.erl, line 138)
ancestors: [<0.83.0>]
message_queue_len: 1
messages: [{'EXIT',<0.85.0>,normal}]
links: [<0.83.0>,<0.44.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 376
stack_size: 28
reductions: 224
neighbours:
=INFO REPORT==== 21-Apr-2021::22:39:21.439000 ===
application: myfirstproj
exited: {bad_return,
{{myfirstproj_app,start,[normal,[]]},
{'EXIT',
{undef,
[{myfirstproj_app,start,[normal,[]],[]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,277}]}]}}}}
type: permanent
我的应用程序代码没有从模板中更改:
%%%-------------------------------------------------------------------
%% @doc myfirstproj public API
%% @end
%%%-------------------------------------------------------------------
-module(myfirstproj_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
myfirstproj_sup:start_link().
stop(_State) ->
ok.
%% internal functions
与我的 app.src 相同:
{application, myfirstproj,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, {myfirstproj_app, []}},
{applications,
[kernel,
stdlib
]},
{env,[]},
{modules, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.
rebar.config尚未从模板中修改。
myfirstproj_sup.erl:
%%%-------------------------------------------------------------------
%% @doc myfirstproj top level supervisor.
%% @end
%%%-------------------------------------------------------------------
-module(myfirstproj_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
-define(SERVER, ?MODULE).
start_link() ->
io:format("Hey, we started!"),
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
init([]) ->
SupFlags = #{strategy => one_for_all,
intensity => 0,
period => 1},
%ChildSpecs = [{worker1,
%{file_watcher, start_link, []}, permanent, 1000, worker, [file_watcher]}],
ChildSpecs = [],
{ok, {SupFlags, ChildSpecs}}.
%% internal functions