rebar3



Build better Erlang.

Ask A Question

Questions

2

rebar3 run crashes, why is that?

### ./src/helloerlang_app.erl ``` %%%------------------------------------------------------------------- %% @doc helloerlang public API %% @end %%%------------------------------------------------------------------- -module(helloerlang_app). -behaviour(application). %% Application callbacks -export([start/2, stop/1, routes/0]). %%==================================================================== %% API %%==================================================================== start(_StartType, _StartArgs) -> Dispatch = cowboy_router:compile([&#123;'_', routes() &#125;]), ok = case cowboy:start_http( helloerlang_http_listener, 100, [&#123;port, 4000&#125;], [&#123;env, [&#123;dispatch, Dispatch&#125;]&#125;]) of &#123;ok, _&#125; -> ok; &#123;error, &#123;already_started, _&#125;&#125; -> ok; &#123;error, _&#125; = Error -> Error end, helloerlang_sup:start_link(). %% helloerlang_sup:start_link(). %%-------------------------------------------------------------------- stop(_State) -> ok. %%==================================================================== %% Internal functions %%==================================================================== routes() -> [ &#123;"/", cowboy_static, &#123;priv_file, helloerlang, "index.html"&#125;&#125; ]. ``` ### ./rebar.config: ``` &#123;erl_opts, [debug_info]&#125;. &#123;deps, [ cowboy ]&#125;. &#123;shell, [ % &#123;config, "config/sys.config"&#125; &#123;apps, [helloerlang]&#125; ]&#125;. &#123;relx, [&#123;release, &#123; local, "0.1.0" &#125;, [helloerlang]&#125;, &#123;dev_mode, true&#125;, &#123;extended_start_script, true&#125;] &#125;. &#123;plugins, [ rebar3_run ]&#125;. ``` ### ./priv_file/index.html ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <p>Test rebar page </p> </body> </html> ``` $ rebar3 compile ===> Verifying dependencies... ===> Compiling helloerlang then $ rebar3 run ===> Verifying dependencies... ===> Compiling helloerlang ===> Starting relx build process ... ===> Resolving OTP Applications from directories: /Users/mincheung/idea_projects/helloerlang/_build/default/lib /usr/local/Cellar/erlang/21.2.2/lib/erlang/lib /Users/mincheung/idea_projects/helloerlang/_build/default/rel ===> Resolved local-0.1.0 ===> Dev mode enabled, release will be symlinked ===> Including Erts from /usr/local/Cellar/erlang/21.2.2/lib/erlang ===> release successfully created! Exec: /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local/erts-10.2.1/bin/erlexec -boot /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local/releases/0.1.0/local -mode embedded -boot_var ERTS_LIB_DIR /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local/lib -config /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local/releases/0.1.0/sys.config -args_file /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local/releases/0.1.0/vm.args -pa -- console Root: /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local /Users/mincheung/idea_projects/helloerlang/_build/default/rel/local Erlang/OTP 21 [erts-10.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace] =CRASH REPORT==== 12-Jan-2019::05:42:21.587864 === crasher: initial call: application_master:init/4 pid: <0.229.0> registered_name: [] exception exit: &#123;bad_return, &#123;&#123;helloerlang_app,start,[normal,[]]&#125;, &#123;'EXIT', &#123;undef, [&#123;cowboy_router,compile, [[&#123;'_', [&#123;"/",cowboy_static, &#123;priv_file,helloerlang,"index.html"&#125;&#125;]&#125;]], []&#125;, &#123;helloerlang_app,start,2, [&#123;file, "/Users/mincheung/idea_projects/helloerlang/src/helloerlang_app.erl"&#125;, &#123;line,18&#125;]&#125;, &#123;application_master,start_it_old,4, [&#123;file,"application_master.erl"&#125;,&#123;line,277&#125;]&#125;]&#125;&#125;&#125;&#125; in function application_master:init/4 (application_master.erl, line 138) ancestors: [<0.228.0>] message_queue_len: 1 messages: [&#123;'EXIT',<0.230.0>,normal&#125;] links: [<0.228.0>,<0.190.0>] dictionary: [] trap_exit: true status: running heap_size: 610 stack_size: 27 reductions: 234 neighbours: =INFO REPORT==== 12-Jan-2019::05:42:21.590625 === application: helloerlang exited: &#123;bad_return, &#123;&#123;helloerlang_app,start,[normal,[]]&#125;, &#123;'EXIT', &#123;undef, [&#123;cowboy_router,compile, [[&#123;'_', [&#123;"/",cowboy_static, &#123;priv_file,helloerlang,"index.html"&#125;&#125;]&#125;]], []&#125;, &#123;helloerlang_app,start,2, [&#123;file, "/Users/mincheung/idea_projects/helloerlang/src/helloerlang_app.erl"&#125;, &#123;line,18&#125;]&#125;, &#123;application_master,start_it_old,4, [&#123;file,"application_master.erl"&#125;,&#123;line,277&#125;]&#125;]&#125;&#125;&#125;&#125; type: permanent Eshell V10.2.1 (abort with ^G) (local@Mins-MBP)1> &#123;"Kernel pid terminated",application_controller,"&#123;application_start_failure,helloerlang,&#123;bad_return,&#123;&#123;helloerlang_app,start,[normal,[]]&#125;,&#123;'EXIT',&#123;undef,[&#123;cowboy_router,compile,[[&#123;'_',[&#123;\"/\",cowboy_static,&#123;priv_file,helloerlang,\"index.html\"&#125;&#125;]&#125;]],[]&#125;,&#123;helloerlang_app,start,2,[&#123;file,\"/Users/mincheung/idea_projects/helloerlang/src/helloerlang_app.erl\"&#125;,&#123;line,18&#125;]&#125;,&#123;application_master,start_it_old,4,[&#123;file,\"application_master.erl\"&#125;,&#123;line,277&#125;]&#125;]&#125;&#125;&#125;&#125;&#125;"&#125; Kernel pid terminated (application_controller) (&#123;application_start_failure,helloerlang,&#123;bad_return,&#123;&#123;helloerlang_app,start,[normal,[]]&#125;,&#123;'EXIT',&#123;undef,[&#123;cowboy_router,compile,[[&#123;'_',[&#123;"/",cowboy_stati Crash dump is being written to: erl_crash.dump...done

Posted by Sebastian Cheung about a month ago

6
ANSWERED

Importing multi-app project

I have a project with multiple OTP apps in it. And I would like to import this project into another project via rebar dependency. And from the new project rebar3 could not see all subprojects defined in the first project. For example, `foo` is parent project and `bar` is trying to include `foo` into it. The app structure for foo looks like this. ``` root@900f642ef568:~/Developer/foo# rebar3 tree ===> Verifying dependencies... ├─ foo─0.1.0 (project app) ├─ foo_app1─0.1.0 (project app) ├─ foo_app2─0.1.0 (project app) └─ foo_app3─0.1.0 (project app) ``` And the directory structure looks like this: ``` root@900f642ef568:~/Developer/foo# tree -d . |-- apps | |-- foo_app1 | | `-- src | |-- foo_app2 | | `-- src | `-- foo_app3 | `-- src `-- src 8 directories ``` I am including this project into another project called bar and after doing `rebar3 get-deps` ``` root@900f642ef568:~/Developer/bar# tree -d . |-- _build | `-- default | `-- lib | `-- foo | |-- apps | | |-- foo_app1 | | | `-- src | | |-- foo_app2 | | | `-- src | | `-- foo_app3 | | `-- src | `-- src `-- src 13 directories ``` And my rebar tree looks like this: ``` root@900f642ef568:~/Developer/bar# rebar3 tree ===> Verifying dependencies... └─ bar─0.1.0 (project app) └─ foo─0.1.0 (git repo) ``` I would like to use `foo_app1` in this project bar (included this in `bar.app.src`). As you can see from the above `rebar3 tree` output, `foo_app1` is not listed as an app that is discovered. Because of which, when I try to launch `bar`, I get the error saying that ``` root@cello:~/Developer/bar# rebar3 shell ===> Verifying dependencies... ===> Compiling bar Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:0] [hipe] [kernel-poll:false] Eshell V9.2 (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) ===> Failed to boot foo_app1 for reason {"no such file or directory", "foo_app1.app"} 1> ``` Can someone please help me how to make rebar3 see the app `foo_app1`?

Posted by Vasu Dasari about a year ago