3
votes

everyone.

I have an erlang application packaged by rebar generate

here is my reltool.config:

{sys, [
   {lib_dirs, ["../../..", "../../deps"]},
   {erts, [{mod_cond, derived}, {app_file, strip}]},
   {app_file, strip},
   {rel, "collector", "1",
    [
     kernel,
     stdlib,
     sasl,
     collector
    ]},
   {rel, "start_clean", "",
    [
     kernel,
     stdlib
    ]},
   {boot_rel, "collector"},
   {profile, embedded},
   {incl_cond, exclude},
   {excl_archive_filters, [".*"]}, %% Do not archive built libs
   {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)",
                       "^erts.*/(doc|info|include|lib|man|src)"]},
   {excl_app_filters, ["\.gitignore"]},
   {app, sasl,   [{incl_cond, include}]},
   {app, stdlib, [{incl_cond, include}]},
   {app, kernel, [{incl_cond, include}]},
   {app, lager, [{incl_cond, include}]},
   {app, goldrush, [{incl_cond, include}]},
   {app, meck, [{incl_cond, include}]},
   {app, mnesia, [{incl_cond, include}]},
   {app, collector, [{incl_cond, include}, {lib_dir, ".."}]}
  ]}.

{target_dir, "collector"}.

{overlay, [
           {mkdir, "log/sasl"},
           {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
           {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"},
           {copy, "files/collector", "bin/collector"},
           {copy, "files/collector.cmd", "bin/collector.cmd"},
           {copy, "files/start_erl.cmd", "bin/start_erl.cmd"},
           {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
           {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
           {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
          ]}.

everything goes smoothly when compiling and packaging:

but when I run the app, it failed to start:

./bin/collector console

the error output:

Exec: /home/crackcell/repo/github/shiyan/collector/rel/collector/erts-5.10.3/bin/erlexec    -boot /home/crackcell/repo/github/shiyan/collector/rel/collector/releases/1/collector -mode embedded -config    /home/crackcell/repo/github/shiyan/collector/rel/collector/releases/1/sys.config -args_file /home/crackcell/repo/github/shiyan/collector/rel/collector/releases/1/vm.args -- console
Root: /home/crackcell/repo/github/shiyan/collector/rel/collector
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

15:34:40.547 [error] CRASH REPORT Process <0.284.0> with 0 neighbours exited with reason: call to undefined function erl_syntax:atom(module) in application_master:init/4 line 133
15:34:40.548 [info] Application lager exited with reason: call to undefined function erl_syntax:atom(module)
{"Kernel pid terminated",application_controller,"{application_start_failure,lager,   {bad_return,{{lager_app,start,[normal,[]]},{'EXIT',{undef,[{erl_syntax,atom,[module],[]},{glc_code,abstract_module_,2,[{file,\"src/glc_code.erl\"},{line,52}]},{glc_code,abstract_module,2,[{file,\"src/glc_code.erl\"},{line,39}]},{glc_code,compile,2,[{file,\"src/glc_code.erl\"},{line,29}]},{glc,compile,2,[{file,\"src/glc.erl\"},{line,171}]},{lager_util,trace_filter,2,[{file,\"src/lager_util.erl\"},{line,366}]},{lager_app,start,2,[{file,\"src/lager_app.erl\"},{line,116}]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,269}]}]}}}}}"}

Crash dump was written to: erl_crash.dump

Kernel pid terminated (application_controller) ({application_start_failure,lager,{bad_return,{{lager_app,start,[normal,[]]},{'EXIT',{undef,[{erl_syntax,atom,[module],[]},{glc_code,abstract_module_,2

seems like main reason of this is {'EXIT',{undef,[{erl_syntax,atom,[module],[]} but I dont know why its undefined(I can use it in console manually) or how to solve it.

btw, Im using Erlang R16B02.

Anybody could help me? thanks.

1

1 Answers

7
votes

erl_syntax is part of syntax_tools (and not stdlib where erl_parse is available). You need to add that explicitly in your rebar config to include it as part of your collector release.

{app, syntax_tools, [{incl_cond, include}]},

Note that whatever is specified in the rebar.config is copied into the release folder and the installed Erlang release is not referred. Hence many tools need to be added explicitly.