Rebar3 + Cowboy Kernel PID Terminated - erlang

I installed rebar3 and created a new release with
cd ~/apps
rebar3 new release tunnel
Then
I copied my src files from ~/tunnel/src/* to ~/apps/tunnel/src/
I ran into a compile error with rebar3 run and found Erlang "Kernel pid terminated" error as a possible solution. I renamed everything about tunnel_app to tunnel. So my src contains tunnel.erl , tunnel.app.src and tunnel_sup.erl. I renamed the module definition as appropriate.
Here's the rebar3 run error:
~/apps/tunnel:.rebar3 run
===> Verifying dependencies...
===> Compiling tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/apps/tunnel/_build/default/lib
/Users/quantum/apps/tunnel/apps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/apps/tunnel/_build/default/rel
===> Resolved tunnel-0.1.0
===> Dev mode enabled, release will be symlinked
===> release successfully created!
readlink: illegal option -- f
usage: readlink [-n] [file ...]
Exec: /usr/local/Cellar/erlang/19.2/lib/erlang/erts-8.2/bin/erlexec -boot /Users/quantum/apps/tunnel/_build/default/rel/tunnel/releases/0.1.0/tunnel -mode embedded -boot_var ERTS_LIB_DIR /usr/local/Cellar/erlang/19.2/lib/erlang/lib -config /Users/quantum/apps/tunnel/_build/default/rel/tunnel/releases/0.1.0/sys.config -args_file /Users/quantum/apps/tunnel/_build/default/rel/tunnel/releases/0.1.0/vm.args -pa -- console
Root: /Users/quantum/apps/tunnel/_build/default/rel/tunnel
/Users/quantum/apps/tunnel/_build/default/rel/tunnel
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:30] [hipe] [kernel-poll:true] [dtrace]
=INFO REPORT==== 16-Feb-2017::15:02:21 ===
application: tunnel
exited: {bad_return,
{{tunnel,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy_router,compile,
[[{'_',
[{"/info",lobby_handler,[]},
{"/join/:name",join_handler,[]},
{"/play/:table_pid/:name/:auth/:team/:action/:x/:y",
play_handler,[]}]}]],
[]},
{tunnel,start,2,
[{file,
"/Users/quantum/apps/tunnel/_build/default/lib/tunnel/src/tunnel.erl"},
{line,8}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{\"/info\",lobby_handler,[]},{\"/join/:name\",join_handler,[]},{\"/play/:table_pid/:name/:auth/:team/:action/:x/:y\",play_handler,[]}]}]],[]},{tunnel,start,2,[{file,\"/Users/quantum/apps/tunnel/_build/default/lib/tunnel/src/tunnel.erl\"},{line,8}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel,start,[normal,[]]},{'EXIT',{undef,[{cowboy_router,compile,[[{'_',[{"/info",lobby_handler,[]},{"/j
Crash dump is being written
Why is this crashing?

If this is your first experience with rebar3, I suggest starting with an OTP application, not an OTP release:
rebar3 new app tunnel
and then do not blindly copy over the source files because you risk overwriting the files that have been created for you below src. Have a look at the contents of that directory beforehand.
I also suggest to take the time to read the rebar3 https://www.rebar3.org/docs/basic-usage page.
You will also have to read about what an OTP application is. I know, quite a lot to understand and sometimes confusing. A free source is http://learnyousomeerlang.com/building-applications-with-otp. It is also worthwhile to buy a book about Erlang. There are a few, I suggest https://www.manning.com/books/erlang-and-otp-in-action.
There is also an online course, free, that starts in a few days (20th Feb 2017) https://www.mooc-list.com/course/functional-programming-erlang-futurelearn

Related

upgrade of erlang applications based on relup by rebar3

I am studying the upgrade of erlang applications based on this article.
But there is some problem when I execute rebar3 relup:
Option --relname is missing
hello#centos7-dev:~/relapp1 ((1.0.12))$ rebar3 relup
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling relapp
Solving Release relapp-1.0.12Resolved relapp-1.0.12release: relapp-1.0.12
erts: 13.0.4
goals:
relapp
parse_trans
sasl
applications:
{kernel,"8.4.2"}
{stdlib,"4.0.1"}
{syntax_tools,"3.0"}
{parse_trans,"3.0.0"}
{relapp,"1.0.12"}
{sasl,"4.2"}
......
....relapp1/_build/default/rel/relapp/lib/sasl-4.2/ebin/sasl.apprelease start script createdRelease successfully assembled:
_build/default/rel/relapp===> Option --relname is missing
The environments are as follows:
erlang
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Eshell V13.0.4 (abort with ^G)
rebar3
rebar 3.20.0 on Erlang/OTP 25 Erts 13.0.4
After many times of retry and experiment, I found it in this article.
Hot code reloading with Erlang and Rebar3
The answer is such as:
rebar3 relup -n nine9s -v "0.2.0" -u "0.1.0"
However, there are some issues which need attention.
The rebar.config file
You should replace the default options {mode, dev} with {dev_mode, false}
the *.appup.src
You cannot include the point_of_no_return option in this file, otherwise there will be some problem such as:
No release upgrade script entry for xxxx-0.2.0 to xxxx-0.1.0 in file

Reason: undef while running common tests in erl console [Erlang]

I have running application and in the interactive console I try to run common test suites located in test/common directory:
ct:run("test/common").
But I get a bunch of errors:
Reason: undef
and all tests fail.
I tried to run them from linux shell
ct_run -dir test/common
or like this:
ct_run -boot start_sasl -spec test/common/app_ct.spec -erl_args -config env/dev.config
with the same result.
But when I run them using rebar (the second version, not rebar3)
rebar ct
Everything works, tests pass. But it takes too much time to compile the app and to start it.
In the rebar.config I have:
{ct_dir,"test/common"}.
{ct_log_dir,"test/logs"}.
{ct_extra_params,"-boot start_sasl -pa deps/*/ebin -pa ebin -spec test/common/app_ct.spec -erl_args -config env/dev.config"}.
and in the test/common/app_ct.spec I have:
{verbosity, 100}.
{init, {eval, [{application, ensure_all_started, [app]}, {timer, sleep, [30000]}]}}.
{alias, common, "./test/common/"}.
{suites, "", [app_srv_SUITE, app_client_SUITE]}.
What can I do to run tests from erl console using ct:run("test/common")?
My goal is to be able to recompile single test files individually and run tests from working application console without stopping and recompiling all application.
I recompile singular test module without problems like this:
c("test/common/new_mod_SUITE.erl", [{i, "include"}, {i, "deps"}, {outdir, "test/common"}]).
But I still can't run tests after that.
First of all, need to be sure that all tests is compiled and they are inside of folder what is put as argument into ct:run/1. If need to run only one test from specific folder, can be used ct:run/2. If need to run specific test case from specific folder, can be used specific folder ct:run/3. Examples:
1> ct:run("test/common").
2> ct:run("test/common", "some_SUITE").
However I would recommend using rebar3, in rebar3 was added option like --dir and tests from specific folder can be run like:
$ ./rebar3 ct --dir="test/common"
This probably won't help, but here is what happens for me using rebar3:
~/erlang_programs/myrebar/myapp$ ls
LICENSE _build rebar.lock test
README.md rebar.config src
~/erlang_programs/myrebar/myapp$ cd src
~/erlang_programs/myrebar/myapp/src$ ls
a.erl myapp_app.erl rebar.lock
myapp.app.src myapp_sup.erl
~/erlang_programs/myrebar/myapp/src$ cat a.erl
-module(a).
-compile(export_all).
%%-include("eunit.hrl").
hello() -> io:format("hello").
~/erlang_programs/myrebar/myapp/src$ cd ../test
~/erlang_programs/myrebar/myapp/test$ ls
a_SUITE.erl
~/erlang_programs/myrebar/myapp/test$ cat a_SUITE.erl
-module(a_SUITE).
-compile(export_all).
all() -> [go].
go(_Config) ->
1 = 1.
~/erlang_programs/myrebar/myapp/test$ cd ..
~/erlang_programs/myrebar/myapp$ rebar3 compile
===> Verifying dependencies...
===> Compiling myapp
~/erlang_programs/myrebar/myapp$ rebar3 shell
===> Verifying dependencies...
===> Compiling myapp
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [kernel-poll:false]
Eshell V9.3 (abort with ^G)
1> ===> The rebar3 shell is a development tool; to deploy applications in production, consider using releases (http://www.rebar3.org/docs/releases)
===> Booted myapp
1> ct:run("test").
Common Test: Running make in test directories...
Recompile: a_SUITE
a_SUITE.erl:2: Warning: export_all flag enabled - all functions will be exported
CWD set to: "/Users/7stud/erlang_programs/myrebar/myapp/ct_run.nonode#nohost.2021-02-14_14.26.08"
TEST INFO: 1 test(s), 1 case(s) in 1 suite(s)
Testing myrebar.myapp: Starting test, 1 test cases
Testing myrebar.myapp: TEST COMPLETE, 1 ok, 0 failed of 1 test cases
Updating /Users/7stud/erlang_programs/myrebar/myapp/index.html ... done
Updating /Users/7stud/erlang_programs/myrebar/myapp/all_runs.html ... done
{1,0,{0,0}}
2>
Then after exiting the shell:
~/erlang_programs/myrebar/myapp$
~/erlang_programs/myrebar/myapp$ rebar3 ct
===> Verifying dependencies...
===> Compiling myapp
test/a_SUITE.erl:2: Warning: export_all flag enabled - all functions will be exported
===> Running Common Test suites...
%%% a_SUITE: .
All 1 tests passed.
~/erlang_programs/myrebar/myapp$
I didn't touch rebar.config, it is the default produced by rebar3:
{erl_opts, [debug_info]}.
{deps, [{eleveldb, "2.2.20"}]
}.
{shell, [
% {config, "config/sys.config"},
{apps, [myapp]}
]}.
I would try printing your current working directory when you are in the shell:
2> pwd().
/Users/7stud/erlang_programs/myrebar/myapp
ok
Then try using either a full path or a relative path from that directory, e.g.:
"./test/common"
"Users/../../test/common"
Then, I would move all your *_SUITE.erl files except one into a directory outside your app, and just work with one test file. Then, I would get rid of all that config file stuff and try again.

Kernel pid terminated application start failure, bad_return

I wrote a cowboy project that I start on localhost with gmake run.
When I make run on a fresh installation, this error happens:
~/tunnel# make run
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[1]: Entering directory `/root/tunnel/deps/cowboy'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Entering directory `/root/tunnel/deps/cowlib'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Leaving directory `/root/tunnel/deps/cowlib'
make[2]: Entering directory `/root/tunnel/deps/ranch'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Leaving directory `/root/tunnel/deps/ranch'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
GEN rebar.config
make[1]: Leaving directory `/root/tunnel/deps/cowboy'
make[1]: Entering directory `/root/tunnel/deps/jiffy'
./rebar compile
==> jiffy (compile)
make[1]: Leaving directory `/root/tunnel/deps/jiffy'
DEPEND tunnel.d
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
ERLC tunnel_app.erl
APP tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/root/tunnel/ebin
/root/tunnel/deps
/usr/local/lib/erlang/lib
/root/tunnel/apps
/root/tunnel/_rel
===> Resolved tunnel_release-1
===> Including Erts from /usr/local/lib/erlang
===> release successfully created!
===> tarball /root/tunnel/_rel/tunnel_release/tunnel_release-1.tar.gz successfully created!
Exec: /root/tunnel/_rel/tunnel_release/erts-9.0/bin/erlexec -boot /root/tunnel/_rel/tunnel_release/releases/1/tunnel_release -mode embedded -boot_var ERTS_LIB_DIR /root/tunnel/_rel/tunnel_release/erts-9.0/../lib -config /root/tunnel/_rel/tunnel_release/releases/1/sys.config -args_file /root/tunnel/_rel/tunnel_release/releases/1/vm.args -- console
Root: /root/tunnel/_rel/tunnel_release
/root/tunnel/_rel/tunnel_release
heart_beat_kill_pid = 16083
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [kernel-poll:false]
=INFO REPORT==== 29-Sep-2017::11:46:35 ===
application: tunnel
exited: {bad_return,
{{tunnel_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_clear,
[my_http_listener,100,
[{port,8080}],
#{env =>
#{dispatch =>
[{'_',[],
[{[<<"info">>],[],lobby_handler,[]},
{[<<"join">>,name],[],join_handler,[]},
{[<<"player">>,<<"status">>,name],
[],player_status_handler,[]},
{[<<"tables">>,<<"info">>,table_id],
[],table_info_handler,[]},
{[<<"tables">>,<<"play">>,table_id,name,auth,
action,x,y],
[],table_play_handler,[]},
{[<<"assets">>,'...'],
[],cowboy_static,
{dir,"/root/tunnel/static/assets/"}}]}]}}],
[]},
{tunnel_app,start,2,[{file,"src/tunnel_app.erl"},{line,17}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,100,[{port,8080}],#{env => #{dispatch => [{'_',[],[{[<<\"info\">>],[],lobby_handler,[]},{[<<\"join\">>,name],[],join_handler,[]},{[<<\"player\">>,<<\"status\">>,name],[],player_status_handler,[]},{[<<\"tables\">>,<<\"info\">>,table_id],[],table_info_handler,[]},{[<<\"tables\">>,<<\"play\">>,table_id,name,auth,action,x,y],[],table_play_handler,[]},{[<<\"assets\">>,'...'],[],cowboy_static,{dir,\"/root/tunnel/static/assets/\"}}]}]}}],[]},{tunnel_app,start,2,[{file,\"src/tunnel_app.erl\"},{line,17}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,100,[{port,8080}],#{
heart: Fri Sep 29 11:46:36 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Fri Sep 29 11:46:36 2017: Would reboot. Terminating.
make: *** [run] Error 1
I see bad return for the tunnel_app
This is my tunnel_app.erl
-module(tunnel_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/info", lobby_handler, []},
{"/join/:name", join_handler, []},
{"/player/status/:name", player_status_handler, []},
{"/tables/info/:table_id", table_info_handler, []},
{"/tables/play/:table_id/:name/:auth/:action/:x/:y", table_play_handler, []},
{"/assets/[...]", cowboy_static, {dir, "/users/quantum/tunnel/static/assets/"}}
]}]),
{ok, _} = cowboy:start_clear(my_http_listener, 100,
[{port, 8080}],
#{env => #{dispatch => Dispatch}}),
{ok, MainDoor} = door:go(),
register(main_door, MainDoor),
{ok, MainRoom} = room:go(),
register(main_room, MainRoom),
tunnel_sup:start_link().
stop(_State) ->
ok.
and the tunnel_sup.erl that it calls with start_link:
-module(tunnel_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
Procs = [],
{ok, {{one_for_one, 1, 5}, Procs}}.
I checked my .gitignore
.erlang.mk/
*.beam
src/*.beam
_rel/
deps/
ebin/
The full repository is here: https://github.com/quantumproductions/tunnel
I'm able to copy a folder on my machine and it works. When I upload this to github and download it, make run fails.
~/tunnel3/ls
Makefile deps erlang.mk rel src tunnel.d
_rel ebin oldh relx.config static
~/tdep/ls
Makefile deps erlang.mk rel src tunnel.d
_rel ebin oldh relx.config static
the second one fails:
~/tdep/gmake run
Error: No Makefile to build dependency /Users/quantum/tdep/deps/cowboy.
gmake: *** [erlang.mk:4182: deps] Error 2
first folder works fine
/tunnel3/gmake run
gmake[1]: Entering directory '/Users/quantum/tunnel3/deps/cowboy'
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/cowlib'
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/cowlib'
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/ranch'
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/ranch'
GEN rebar.config
gmake[1]: Leaving directory '/Users/quantum/tunnel3/deps/cowboy'
gmake[1]: Entering directory '/Users/quantum/tunnel3/deps/jiffy'
CC=gcc ./enc compile
gmake -f c_src/Makefile.erlang.mk
gmake[2]: Entering directory '/Users/quantum/tunnel3/deps/jiffy'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/Users/quantum/tunnel3/deps/jiffy'
gmake[1]: Leaving directory '/Users/quantum/tunnel3/deps/jiffy'
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/tunnel3/ebin
/Users/quantum/tunnel3/deps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/tunnel3/apps
/Users/quantum/tunnel3/_rel
What configuration could be causing this?
EDIT:
Juanjo Martin's answer works, in my cloned folder.
In my original folder, it does not, and removing the 100 argument gets me the below.
Why is this not working in 1 specific folder? What kind of environment fix do I have to check/make to prevent this? It seems like ~/tunnel is running a different version of cowboy?
/tunnel/gmake run
gmake[1]: Entering directory '/Users/quantum/tunnel/deps/cowboy'
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/cowlib'
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/cowlib'
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/ranch'
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/ranch'
GEN rebar.config
gmake[1]: Leaving directory '/Users/quantum/tunnel/deps/cowboy'
gmake[1]: Entering directory '/Users/quantum/tunnel/deps/jiffy'
CC=gcc ./enc compile
gmake -f c_src/Makefile.erlang.mk
gmake[2]: Entering directory '/Users/quantum/tunnel/deps/jiffy'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/Users/quantum/tunnel/deps/jiffy'
gmake[1]: Leaving directory '/Users/quantum/tunnel/deps/jiffy'
DEPEND tunnel.d
ERLC tunnel_app.erl
APP tunnel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/Users/quantum/tunnel/ebin
/Users/quantum/tunnel/deps
/usr/local/Cellar/erlang/19.2/lib/erlang/lib
/Users/quantum/tunnel/apps
/Users/quantum/tunnel/_rel
===> Resolved tunnel_release-1
===> Including Erts from /usr/local/Cellar/erlang/19.2/lib/erlang
===> release successfully created!
===> tarball /Users/quantum/tunnel/_rel/tunnel_release/tunnel_release-1.tar.gz successfully created!
Exec: /Users/quantum/tunnel/_rel/tunnel_release/erts-8.2/bin/erlexec -boot /Users/quantum/tunnel/_rel/tunnel_release/releases/1/tunnel_release -mode embedded -boot_var ERTS_LIB_DIR /Users/quantum/tunnel/_rel/tunnel_release/erts-8.2/../lib -config /Users/quantum/tunnel/_rel/tunnel_release/releases/1/sys.config -args_file /Users/quantum/tunnel/_rel/tunnel_release/releases/1/vm.args -- console
Root: /Users/quantum/tunnel/_rel/tunnel_release
/Users/quantum/tunnel/_rel/tunnel_release
heart_beat_kill_pid = 3135
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
=INFO REPORT==== 5-Oct-2017::16:54:36 ===
application: tunnel
exited: {bad_return,
{{tunnel_app,start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy,start_clear,
[my_http_listener,
[{port,8080}],
#{env => #{dispatch => [{'_',[],
[{[<<"info">>],[],lobby_handler,[]},
{[<<"join">>,name],
[],join_handler,[]},
{[<<"player">>,<<"status">>,name],
[],player_status_handler,[]},
{[<<"tables">>,<<"info">>,table_id],
[],table_info_handler,[]},
{[<<"tables">>,<<"play">>,table_id,
name,auth,action,x,y],
[],table_play_handler,[]},
{[<<"assets">>,'...'],
[],cowboy_static,
{dir,
"/users/quantum/tunnel/static/assets/"}}]}]}}],
[]},
{tunnel_app,start,2,
[{file,"src/tunnel_app.erl"},{line,17}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},
{line,273}]}]}}}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,[{port,8080}],#{env => #{dispatch => [{'_',[],[{[<<\"info\">>],[],lobby_handler,[]},{[<<\"join\">>,name],[],join_handler,[]},{[<<\"player\">>,<<\"status\">>,name],[],player_status_handler,[]},{[<<\"tables\">>,<<\"info\">>,table_id],[],table_info_handler,[]},{[<<\"tables\">>,<<\"play\">>,table_id,name,auth,action,x,y],[],table_play_handler,[]},{[<<\"assets\">>,'...'],[],cowboy_static,{dir,\"/users/quantum/tunnel/static/assets/\"}}]}]}}],[]},{tunnel_app,start,2,[{file,\"src/tunnel_app.erl\"},{line,17}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,273}]}]}}}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,tunnel,{bad_return,{{tunnel_app,start,[normal,[]]},{'EXIT',{undef,[{cowboy,start_clear,[my_http_listener,[{port,8080}],#{env
heart: Thu Oct 5 16:54:37 2017: Erlang is crashing .. (waiting for crash dump file)
heart: Thu Oct 5 16:54:37 2017: Would reboot. Terminating.
gmake: *** [erlang.mk:6450: run] Error 1
~/tunnel/
Aha. I did the comment's instruction from #lastcanal and it works. Thanks.
First thing I see is you don't have an .app file
You can check a similar problem in why-is-my-cowboy-server-not-running
flag
In tunnel_app.erl module you're calling cowboy:start_clear with an arity of 4 but the arity for this function is 3. That's why the undef error:
exited: {bad_return, {{tunnel_app,start,[normal,[]]}, {'EXIT', {undef, [{cowboy,start_clear, [my_http_listener,100, [{port,8080}],
... You should remove the parameter "100"
This must have been from an earlier version of Cowboy, possibly

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

rebar: error exit on create-app: {crypto,start,[]}

I followed the instructions here, to the letter. I then ran the instruction to create an application project structure, and got the following error.
$ ./rebar create-app appid=myapp
Uncaught error in rebar_core: {'EXIT',
{undef,
[{crypto,start,[]},
{rebar_core,run,1},
{rebar,main,1},
{escript,run,2},
{escript,start,1},
{init,start_it,1},
{init,start_em,1}]}}
Any ideas what I'm doing wrong?
It looks like your Erlang was compiled without OpenSSL (the crypto module). crypto is required for many (most?) Erlang applications. You'll need to get a version of Erlang with a working crypto module, and then you shouldn't have any problems like this.
A clarification to YOUR ARGUMENT IS VALID's answer (adding as an answer because the comment is too short).
It may be that Erlang was compiled properly but the OpenSSL libraries are not visible to Erlang, so the crypto server can't be started. I compiled Erlang on Solaris 10 and it didn't complain about OpenSSL not being installed. In fact, it compiled crypto and installed it in: /usr/local/lib/erlang/lib/crypto-2.2/
But Rebar still wasn't working. It's easy to check if the problem is indeed with the crypto module.
Open Erlang shell and type crypto:start(). This was happening on my system:
bash-3.2# erl
Erlang R15B03 (erts-5.9.3.1) [source] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.3.1 (abort with ^G)
1> crypto:start().
** exception error: undefined function crypto:start/0
2>
=ERROR REPORT==== 8-Feb-2013::15:28:43 ===
Unable to load crypto library. Failed with error:
"load_failed, Failed to load NIF library: 'ld.so.1: beam.smp: fatal: relocation error: file /usr/local/lib/erlang/lib/crypto-2.2/priv/lib/crypto.so: symbol DES_ede3_cfb_encrypt: referenced symbol not found'"
OpenSSL might not be installed on this system.
=ERROR REPORT==== 8-Feb-2013::15:28:43 ===
The on_load function for module crypto returned {error,
{load_failed,
"Failed to load NIF library: 'ld.so.1: beam.smp: fatal: relocation error: file /usr/local/lib/erlang/lib/crypto-2.2/priv/lib/crypto.so: symbol DES_ede3_cfb_encrypt: referenced symbol not found'"}}
If OpenSSL is installed in a non-standard location, as it is the case when using OpenCSW to install OpenSSL on Solaris 10, it is easy to fix the problem by adding the library path to the environment variable. For example on Solaris 10 to /etc/profile:
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/csw/lib
export LD_LIBRARY_PATH
Then log-out and log-in or re-load the bash environment, for example like this:
bash-3.2# . /etc/profile
Result:
bash-3.2# erl
Erlang R15B03 (erts-5.9.3.1) [source] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.3.1 (abort with ^G)
1> crypto:start().
ok
I'd recommend using precompiled Erlang which is available from Erlang Solutions: https://www.erlang-solutions.com/downloads/download-erlang-otp
There's one for Windows too.
Getting this error when running make command:
root#hs:/var/www/html/ejabberd-master# make
rm -rf deps/.got
rm -rf deps/.built
/usr/local/lib/erlang/bin/escript rebar get-deps && :> deps/.got
Uncaught error in rebar_core: {'EXIT',
{undef,
[{crypto,start,[],[]},
{rebar,run_aux,2,
[{file,"src/rebar.erl"},{line,163}]},
{rebar,main,1,
[{file,"src/rebar.erl"},{line,58}]},
{escript,run,2,
[{file,"escript.erl"},{line,757}]},
{escript,start,1,
[{file,"escript.erl"},{line,277}]},
{init,start_it,1,[]},
{init,start_em,1,[]}]}}
make: *** [deps/.got] Error 1
The erlang details are:
root#hs:/home/node# erl
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async- threads:10] [hipe] [kernel-poll:false]
Eshell V7.0 (abort with ^G)
1> crypto:start()
1>
Seems like crypto not working, as the command gives "Ok" or "exception error".
Help needed.
Thanks for the answer Ivan. But it seems I figured out the issue:
The ubuntu auto updates were turned off and the dependencies were not installed while compiling erlang (e.g. libssh-dev). Once the auto update was turned on it compiled and make command ran fine.

Resources