Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store rustler template outside of priv/? #516

Closed
evnu opened this issue Feb 10, 2023 · 2 comments · Fixed by #559
Closed

Store rustler template outside of priv/? #516

evnu opened this issue Feb 10, 2023 · 2 comments · Fixed by #559

Comments

@evnu
Copy link
Member

evnu commented Feb 10, 2023

The templates are stored in rustler_mix/priv/templates. When rustler_mix is part of a deployed Erlang/Elixir release, the priv directory is usually copied as-is into the release, so the templates end up in a deployed location. Maybe we can move the templates into another directory and tell package/0 in Rustler.Mixfile to include that directory as well.

@hauleth
Copy link

hauleth commented Feb 16, 2023

AFAIK rustler Elixir library is compile time only, so you can add runtime: false to your dependency and it will not be included into the release.

@evnu
Copy link
Member Author

evnu commented Aug 17, 2023

I just tried that, but alas runtime: false does not (yet) work for a release, as Rustler.construct_load_data/2 is compiled into the module:

/tmp/test_rustler_mix/_build/dev/rel/test_rustler_mix/bin ./test_rustler_mix start_iex
=ERROR REPORT==== 17-Aug-2023::23:17:52.044812 ===
Error in process <0.585.0> with exit value:
{undef,[{'Elixir.Rustler',construct_load_data,[0,nil],[]},
        {'Elixir.RustlerMixTest',rustler_init,0,
                                 [{file,"lib/rustler_mix_test.ex"},{line,1}]},
        {init,'-run_on_load_handler/2-fun-0-',1,[]}]}

=CRASH REPORT==== 17-Aug-2023::23:17:52.045100 ===
  crasher:
    initial call: kernel:init/1
    pid: <0.584.0>
    registered_name: []
    exception exit: {on_load_function_failed,'Elixir.RustlerMixTest',
                        {undef,
                            [{'Elixir.Rustler',construct_load_data,[0,nil],[]},
                             {'Elixir.RustlerMixTest',rustler_init,0,
                                 [{file,"lib/rustler_mix_test.ex"},{line,1}]},
                             {init,'-run_on_load_handler/2-fun-0-',1,[]}]}}
      in function  init:run_on_load_handlers/0
      in call from kernel:init/1 (kernel.erl, line 227)
    ancestors: [kernel_sup,<0.577.0>]
    message_queue_len: 0
    messages: []
    links: [<0.579.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 376
    stack_size: 28
    reductions: 145
  neighbours:

=SUPERVISOR REPORT==== 17-Aug-2023::23:17:52.045132 ===
    supervisor: {local,kernel_sup}
    errorContext: start_error
    reason: {on_load_function_failed,'Elixir.RustlerMixTest',
                {undef,
                    [{'Elixir.Rustler',construct_load_data,[0,nil],[]},
                     {'Elixir.RustlerMixTest',rustler_init,0,
                         [{file,"lib/rustler_mix_test.ex"},{line,1}]},
                     {init,'-run_on_load_handler/2-fun-0-',1,[]}]}}
    offender: [{pid,undefined},
               {id,on_load},
               {mfargs,{proc_lib,start_link,[kernel,init,[on_load]]}},
               {restart_type,transient},
               {significant,false},
               {shutdown,2000},
               {child_type,worker}]

=CRASH REPORT==== 17-Aug-2023::23:17:52.049175 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.576.0>
    registered_name: []
    exception exit: {{shutdown,
                      {failed_to_start_child,on_load,
                       {on_load_function_failed,'Elixir.RustlerMixTest',
                        {undef,
                         [{'Elixir.Rustler',construct_load_data,[0,nil],[]},
                          {'Elixir.RustlerMixTest',rustler_init,0,
                           [{file,"lib/rustler_mix_test.ex"},{line,1}]},
                          {init,'-run_on_load_handler/2-fun-0-',1,[]}]}}}},
                     {kernel,start,[normal,[]]}}
      in function  application_master:init/4 (application_master.erl, line 142)
    ancestors: [<0.575.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.577.0>,normal}]
    links: [<0.575.0>,<0.574.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 610
    stack_size: 28
    reductions: 171
  neighbours:

=INFO REPORT==== 17-Aug-2023::23:17:52.049671 ===
    application: kernel
    exited: {{shutdown,
                 {failed_to_start_child,on_load,
                     {on_load_function_failed,'Elixir.RustlerMixTest',
                         {undef,
                             [{'Elixir.Rustler',construct_load_data,
                                  [0,nil],
                                  []},
                              {'Elixir.RustlerMixTest',rustler_init,0,
                                  [{file,"lib/rustler_mix_test.ex"},{line,1}]},
                              {init,'-run_on_load_handler/2-fun-0-',1,[]}]}}}},
             {kernel,start,[normal,[]]}}
    type: permanent

Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,on_load,{on_load_function_failed,'Elixir.RustlerMixTest',{undef,[{'Elixir.Rustler',construct_load_data,[0,nil],[]},{'Elixir.RustlerMixTest',rustler_init,0,[{file,"lib/rustler_mix_test.ex"},{line,1}]},{init,'-run_on_load_handler/2-fun-0-',1,[]}]}}}},{kernel,start,[normal,[]]}}})

I think it should be possible to do that before runtime though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants