1

(这里是新手)尝试运行牧场示例时出现错误。通过rebar我创建了应用程序和节点(请参阅github)。但是当我尝试构建和运行它时,我得到了undef ranch,start_listener.

请查看完整的控制台输出:

$ rebar get-deps compile generate && sh rel/reverse/bin/reverse console
WARN:  Expected reverse/deps/ranch to be an app dir (containing ebin/*.app), but no .app found.
==> rel (get-deps)
==> reverse (get-deps)
WARN:  Expected reverse/deps/ranch to be an app dir (containing ebin/*.app), but no .app found.
Pulling ranch from {git,"git@github.com:ninenines/ranch.git",{tag,"1.1.0"}}
Cloning into 'ranch'...
==> ranch (get-deps)
==> ranch (compile)
Compiled src/ranch_transport.erl
Compiled src/ranch_sup.erl
Compiled src/ranch_ssl.erl
Compiled src/ranch_tcp.erl
Compiled src/ranch_protocol.erl
Compiled src/ranch_listener_sup.erl
Compiled src/ranch_app.erl
Compiled src/ranch_acceptors_sup.erl
Compiled src/ranch_acceptor.erl
Compiled src/ranch_server.erl
Compiled src/ranch.erl
Compiled src/ranch_conns_sup.erl
==> rel (compile)
==> reverse (compile)
Compiled src/reverse_sup.erl
Compiled src/reverse_app.erl
Compiled src/reverse_protocol.erl
==> rel (generate)
WARN:  'generate' command does not apply to directory reverse
Exec: reverse/rel/reverse/erts-6.3/bin/erlexec  -boot reverse/rel/reverse/releases/1/reverse -mode embedded -config reverse/rel/reverse/releases/1/sys.config -args_file reverse/rel/reverse/releases/1/vm.args -- console
Root: reverse/rel/reverse
Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
(reverse@127.0.0.1)1> 
=INFO REPORT==== 30-Dec-2014::22:47:08 ===
    application: reverse
    exited: {bad_return,
                {{reverse_app,start,[normal,[]]},
                 {'EXIT',
                     {undef,
                         [{ranch,start_listener,
                              [reverse,10,ranch_tcp,
                               [{port,5555}],
                               reverse_protocol,[]],
                              []},
                          {reverse_app,start,2,
                              [{file,"src/reverse_app.erl"},{line,13}]},
                          {application_master,start_it_old,4,
                              [{file,"application_master.erl"},
                               {line,272}]}]}}}}
    type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,reverse,{bad_return,{{reverse_app,start,[normal,[]]},{'EXIT',{undef,[{ranch,start_listener,[reverse,10,ranch_tcp,[{port,5555}],reverse_protocol,[]],[]},{reverse_app,start,2,[{file,\"src/reverse_app.erl\"},{line,13}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,272}]}]}}}}}"}

Crash dump was written to: erl_crash.dump

我不确定我是否正确添加ranchreltool.config请参阅 github)。但是如果我depslibs_dir路径中删除,我会得到rebar generate错误Application version clash. Multiple directories contain version ...

更新如果我删除失败的呼叫并运行它,则将application:which_applications().{ranch,[],[]}作为正在运行的呼叫之一。

更新版本

$ erl
Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

$ rebar --version
rebar 2.5.1 17 20141223_141030 git 2.5.1-84-gdd9125e

我做错了什么?

提前致谢!

4

1 回答 1

2

在 中,从 Ranch 的路径中reltool.config删除目录:ebin

{app, ranch, [{mod_cond, app}, {incl_cond, include}, {lib_dir, "../deps/ranch/"}]}

如果您有很多依赖项,这样做会更方便:

{lib_dirs, ["../deps"]}

{app, <dep_name>, [...]}而不是为每个依赖项单独设置。

Application version clash. Multiple directories contain version XXX错误表明已经安装了Ranch应用程序,可能在Erlang lib目录中,与Rebar下载的deps版本冲突。

于 2014-12-31T10:07:32.850 回答