简体   繁体   中英

My Erlang application don't see ranch module dependency

(Newbie here) I am having an error when trying to run ranch example . Via rebar I created application and node (please see on github ). But when I am trying to build and run it I am getting undef ranch,start_listener .

Please see full console output:

$ 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

I am not sure I correctly added ranch to reltool.config ( please see on github ). But If I remove deps from libs_dir path I will get rebar generate error Application version clash. Multiple directories contain version ... Application version clash. Multiple directories contain version ... .

UPDATE if I remove failing call and run it, application:which_applications(). gives me {ranch,[],[]} as one of the running ones.

UPDATE versions

$ 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

What I am doing wrong?

Thanks in advance!

In the reltool.config , remove the ebin directory from the path to Ranch:

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

If you have lots of dependencies it's more convenient to do:

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

instead of having a separate {app, <dep_name>, [...]} for each dependency.

The Application version clash. Multiple directories contain version XXX Application version clash. Multiple directories contain version XXX error indicates that the Ranch application is already installed, probably in the Erlang lib directory, creating conflicts with the deps version downloaded by Rebar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM