[erlang-questions] trouble creating releases with rebar, apps exit with 'bad_return'

Todd t.greenwoodgeer@REDACTED
Tue Apr 26 05:56:20 CEST 2011


Mike -
Thanks for your suggestions. The create-node instructions are definitely 
part of the skeptomai tutorial.

For any other newbies that run into this, I think the culprit was that I 
was running R13. I just compiled and installed R14B02 from source, and 
then ran thru the skeptomai tutorial...works like a charm.

So, if you, too, are getting the dread, 'bad_return', make sure you 
aren't running R13*.

-Todd

On 4/25/11 1:34 AM, Mike Oxford wrote:
> You will need to create a node before you can generate a release.
>
> create 'rel' directory and cd into it
> rebar -v create-node nodeid=<nodename>
> Modify the generated reltool.config file
> rebar -v generate
>
> Subsequent generate calls will need to have "force=1" added to overwrite
> the previously generated node.
>
> After you have a node generated, ex: nodeid=moxnode, then you can launch
> with boot scripts...
> rel/<nodeid>/bin/<nodeid> start
>
> Look in Alan's link for ... "To create a release we have to create a new
> directory in the root of our project called *rel* and create a node in
> it. A node is kind of a standalone Erlang VM for our application to run on."
> That looks like what you're missing.
>
> Another perspective...
> https://bitbucket.org/basho/rebar/wiki/ReleaseHandling
>
>
> -mox
>
>
>
> On Sun, Apr 24, 2011 at 9:01 PM, Todd <t.greenwoodgeer@REDACTED
> <mailto:t.greenwoodgeer@REDACTED>> wrote:
>
>     Short version:
>     When I create a release with rebar, the app dies with 'bad_return'.
>
>     Longer version:
>     (rebar version: 2 date: 20110420_043817 vcs: git bd1475d)
>
>     1. I've tried following these two rebar tutorials:
>
>     http://skeptomai.com/?p=56#respond
>     http://alancastro.org/2010/05/01/erlang-application-management-with-rebar.html
>
>     2. Following either set of instructions, I can generate a single app
>     and subsequently compile and launch it in the erl shell:
>
>     rebar create-app
>     rebar compile
>     erl -pa ebin
>
>         application:start(myapp).
>         application:stop(myapp).
>
>
>     3. So far, so good. However, things seem to fall apart in the 'rebar
>     -v generate' command...but then, I'm not sure what I should be
>     seeing here:
>
>     user@REDACTED:~/projects/testing-rebar-03/mysample$ rebar -v generate
>     DEBUG: Rebar location: "/usr/local/bin/rebar"
>     DEBUG: Entering /home/user/projects/testing-rebar-03/mysample
>     DEBUG: Available deps: []
>     DEBUG: Missing deps  : []
>     DEBUG: Predirs: ["/home/user/projects/testing-rebar-03/mysample/rel"]
>     DEBUG: Entering /home/user/projects/testing-rebar-03/mysample/rel
>     DEBUG: Available deps: []
>     DEBUG: Missing deps  : []
>     DEBUG: Predirs: []
>     ==> rel (generate)
>     DEBUG: Created dir
>     /home/user/projects/testing-rebar-03/mysample/rel/mysample/log/sasl
>     INFO:  sh info:
>             cwd: "/home/user/projects/testing-rebar-03/mysample/rel"
>             cmd: cp -R
>     /home/user/projects/testing-rebar-03/mysample/rel/files/erl
>     /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/erl
>             opts: [{use_stdout,false},return_on_error]
>     INFO:  sh info:
>             cwd: "/home/user/projects/testing-rebar-03/mysample/rel"
>             cmd: cp -R
>     /home/user/projects/testing-rebar-03/mysample/rel/files/nodetool
>     /home/user/projects/testing-rebar-03/mysample/rel/mysample/erts-5.7.5/bin/nodetool
>             opts: [{use_stdout,false},return_on_error]
>     INFO:  sh info:
>             cwd: "/home/user/projects/testing-rebar-03/mysample/rel"
>             cmd: cp -R
>     /home/user/projects/testing-rebar-03/mysample/rel/files/mysample
>     /home/user/projects/testing-rebar-03/mysample/rel/mysample/bin/mysample
>             opts: [{use_stdout,false},return_on_error]
>     INFO:  sh info:
>             cwd: "/home/user/projects/testing-rebar-03/mysample/rel"
>             cmd: cp -R
>     /home/user/projects/testing-rebar-03/mysample/rel/files/app.config
>     /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/app.config
>             opts: [{use_stdout,false},return_on_error]
>     INFO:  sh info:
>             cwd: "/home/user/projects/testing-rebar-03/mysample/rel"
>             cmd: cp -R
>     /home/user/projects/testing-rebar-03/mysample/rel/files/vm.args
>     /home/user/projects/testing-rebar-03/mysample/rel/mysample/etc/vm.args
>             opts: [{use_stdout,false},return_on_error]
>     DEBUG: Postdirs: []
>     WARN: 'generate' command does not apply to directory
>     /home/user/projects/testing-rebar-03/mysample
>     DEBUG: Postdirs: []
>
>     4. However, the true error shows when I try to start the rebar
>     created app:
>
>     user@REDACTED:~/projects/testing-rebar-01$ sh rel/mynode/bin/mynode
>     console
>     Exec:
>     /home/user/projects/testing-rebar-01/rel/mynode/erts-5.7.5/bin/erlexec
>     -boot
>     /home/user/projects/testing-rebar-01/rel/mynode/releases/1/mynode
>     -embedded -config
>     /home/user/projects/testing-rebar-01/rel/mynode/etc/app.config
>     -args_file
>     /home/user/projects/testing-rebar-01/rel/mynode/etc/vm.args -- console
>     Root: /home/user/projects/testing-rebar-01/rel/mynode
>     Erlang R13B04 (erts-5.7.5) [source] [rq:1] [async-threads:5]
>     [kernel-poll:true]
>
>
>     =INFO REPORT==== 19-Apr-2011::22:51:20 ===
>         application: myapp
>         exited: {bad_return,
>                     {{myapp_app,start,[normal,[]]},
>                      {'EXIT',
>                          {undef,
>                              [{myapp_app,start,[normal,[]]},
>                               {application_master,start_it_old,4}]}}}}
>         type: permanent
>     {"Kernel pid
>     terminated",application_controller,"{application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it_old,4}]}}}}}"}
>
>     Crash dump was written to: erl_crash.dump
>     Kernel pid terminated (application_controller)
>     ({application_start_failure,myapp,{bad_return,{{myapp_app,start,[normal,[]]},{'EXIT',{undef,[{myapp_app,start,[normal,[]]},{application_master,start_it
>
>
>     5. I have tried creating and releasing apps via rebar using both
>     sets of instructions, on both mac os x, and linux, multiple times...
>     and in all cases, I've run into the 'bad_return' when attempting to
>     start the app.
>
>     6. I see that this question has been raised before:
>
>     https://groups.google.com/group/erlang-programming/browse_thread/thread/47961ad971086582
>
>     5. And the idea was that the app wasn't being compiled (or the
>     compiled files couldn't be found). Well, I can see the app being
>     compiled here:
>
>     user@REDACTED:~/projects/testing-rebar-01$ rebar compile
>     ==> myapp (compile)
>     ==> rel (compile)
>     ==> testing-rebar-01 (compile)
>
>     6. And when I generate the release, it's all new:
>
>     user@REDACTED:~/projects/testing-rebar-01$ rm -rf rel/mynode/ &&
>     rebar generate && sh rel/mynode/bin/mynode console
>
>     7. However, the generated release looks suspicious... for one thing,
>     my app files are not in the release dir:
>
>     user@REDACTED:~/projects/testing-rebar-01$ find . | grep myapp
>     ./apps/myapp
>     ./apps/myapp/src
>     ./apps/myapp/src/myapp_app.erl
>     ./apps/myapp/src/myapp.app.src
>     ./apps/myapp/src/myapp_sup.erl
>     ./apps/myapp/ebin
>     ./apps/myapp/ebin/myapp_app.beam
>     ./apps/myapp/ebin/myapp_sup.beam
>     ./apps/myapp/ebin/myapp.app
>
>
>     8. For another thing, my app beam files are not in the release dir,
>     either:
>
>     user@REDACTED:~/projects/testing-rebar-01$ find . | grep beam
>     ./apps/myapp/ebin/myapp_app.beam
>     ./apps/myapp/ebin/myapp_sup.beam
>     ./rel/mynode/erts-5.7.5/bin/beam.smp
>     ./rel/mynode/erts-5.7.5/bin/beam
>
>     9. Could someone show me what's supposed to be generated from the
>     rebar generate command? Specifically, what files do I need to look
>     at to verify that my application files have properly compiled into
>     the release?
>
>     10. Also, any hints as to how one should approach this sort of
>     problem, debugging hints, etc. are always appreciated.
>
>
>     ----------------
>     files
>     ----------------
>     user@REDACTED:~/projects/testing-rebar-01$ cat rebar.config
>     {sub_dirs, ["apps/myapp", "rel"]}.
>     user@REDACTED:~/projects/testing-rebar-01$ cat rel/reltool.config
>     {sys, [
>            {lib_dirs, ["../apps"]},
>            {rel, "mynode", "1",
>             [
>              myapp,
>              kernel,
>              stdlib,
>              sasl
>             ]},
>            {rel, "start_clean", "",
>             [
>              kernel,
>              stdlib
>             ]},
>            {boot_rel, "mynode"},
>            {profile, embedded},
>            {excl_sys_filters, ["^bin/.*",
>     "^erts.*/bin/(dialyzer|typer)"]},
>            {app, sasl, [{incl_cond, include}]}
>           ]}.
>
>     {target_dir, "mynode"}.
>
>     {overlay, [
>                {mkdir, "log/sasl"},
>                {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
>                {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"},
>                {copy, "files/mynode", "bin/mynode"},
>                {copy, "files/app.config", "etc/app.config"},
>                {copy, "files/vm.args", "etc/vm.args"}
>               ]}.
>
>
>     Thanks,
>
>     -Todd
>     _______________________________________________
>     erlang-questions mailing list
>     erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>     http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list