【问题标题】:My Erlang application don't see ranch module dependency我的 Erlang 应用程序看不到牧场模块依赖项
【发布时间】:2015-02-27 01:06:08
【问题描述】:

(这里是新手)尝试运行ranch example 时出现错误。 通过rebar 我创建了应用程序和节点(请参阅github)。 但是当我尝试构建和运行它时,我得到了undefranch,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

我不确定我是否正确地将ranch 添加到reltool.config (please see on github)。但是如果我从libs_dir 路径中删除deps,我会得到rebar generate 错误Application version clash. Multiple directories contain version ...

更新如果我删除 failing call 并运行它,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

我做错了什么?

提前致谢!

【问题讨论】:

    标签: erlang rebar ranch


    【解决方案1】:

    reltool.config中,从Ranch的路径中删除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版本冲突。

    【讨论】:

    • 删除deps 会给我Application version clash 错误,正如我在问题中所写的那样。
    • 如果我完全删除 {app, ranch, [...]} 并添加 {lib_dirs, ["../deps"]} 而不是我得到 {"init terminating in do_boot",{'cannot load',ranch_sup,get_files}}
    • R17 + 钢筋 2.1.0。您是否在其他地方手动安装了 Ranch?听起来 rebar 找到了它的多个版本。
    • 奇怪,这可能是个问题。我在我的机器中寻找ranch,发现:/usr/local/lib/erlang/lib/ranch-1.0.1。我应该删除它吗?
    • 是的,删除它,这可能是问题所在。
    猜你喜欢
    • 2019-10-20
    • 2012-10-29
    • 2020-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 2015-03-25
    • 1970-01-01
    相关资源
    最近更新 更多