1

(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 ....

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!

Dmytro Starosud
  • 397
  • 1
  • 15

1 Answers1

2

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 error indicates that the Ranch application is already installed, probably in the Erlang lib directory, creating conflicts with the deps version downloaded by Rebar.

johlo
  • 5,422
  • 1
  • 18
  • 32
  • Removing `deps` gives me `Application version clash` error as I wrote in the question. – Dmytro Starosud Dec 31 '14 at 10:46
  • If I completely remove `{app, ranch, [...]}` and add `{lib_dirs, ["../deps"]}` instead I get `{"init terminating in do_boot",{'cannot load',ranch_sup,get_files}}`. – Dmytro Starosud Dec 31 '14 at 10:48
  • I cloned your repo and tried my `{app, ranch, ...}` patch, works fine for me. Also removing that line and doing `{lib_dirs, ["../deps"]}` works as expected. – johlo Dec 31 '14 at 11:04
  • Looks good :) Now let us figure out the difference between our environments. Which versions of Erlang and rebar are you using? (I added version info into question) – Dmytro Starosud Dec 31 '14 at 11:09
  • 1
    R17 + Rebar 2.1.0. Have you installed Ranch manually somewhere else? sounds like rebar finds multiple versions of it. – johlo Dec 31 '14 at 11:17
  • 1
    Strange, probably this is an issue. I looked for `ranch` in my machine and found: `/usr/local/lib/erlang/lib/ranch-1.0.1`. Should I delete it? – Dmytro Starosud Dec 31 '14 at 11:33
  • 2
    Yes, remove it, that's likely the problem. – johlo Dec 31 '14 at 11:42
  • If you download the Erlang Solutions Enterprise package, it includes ranch and other applications in the system erlang lib directory. – kjw0188 Jul 30 '15 at 23:52