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

"rebar3 as prod tar" overlay does not take effect #921

Open
leonlee2007 opened this issue Jun 29, 2022 · 1 comment
Open

"rebar3 as prod tar" overlay does not take effect #921

leonlee2007 opened this issue Jun 29, 2022 · 1 comment

Comments

@leonlee2007
Copy link

When upgrading rebar3 of an umbrella project from 3.12 to 3.19, I encounter a problem:
Packaging with rebar3 as prod tar, it is found that the overlay configured in the app does not replace the general overlay.
but rebar3 as prod release is ok.

Try to modify the code of relx.erl:
https://github.com/erlware/relx/blob/main/src/relx.erl

build_release_(#{name := RelName,
                 vsn := RelVsn}, Apps, State) ->
    Release = rlx_state:get_configured_release(State, RelName, RelVsn),
    {ok, RealizedRelease, State1} =
        rlx_resolve:solve_release(Release, rlx_state:available_apps(State, Apps)),
    {ok, State2} = rlx_assemble:do(RealizedRelease, State1),
    _ = rlx_overlay:render(RealizedRelease, State2),
    RealizedRelease.

build_tar(Release=#{name := RelName,
                    vsn := RelVsn}, Apps, State) when is_atom(RelName) ,
                                                      is_list(RelVsn) ->
    RealizedRelease = build_release_(Release, Apps, State),
    build_tar_(RealizedRelease, State),
    {ok, RealizedRelease};

Change it to the following:

build_release_(#{name := RelName,
                 vsn := RelVsn}, Apps, State) ->
    Release = rlx_state:get_configured_release(State, RelName, RelVsn),
    {ok, RealizedRelease, State1} =
        rlx_resolve:solve_release(Release, rlx_state:available_apps(State, Apps)),
    {ok, State2} = rlx_assemble:do(RealizedRelease, State1),
    _ = rlx_overlay:render(RealizedRelease, State2),
    %RealizedRelease.
    {ok, State2, RealizedRelease}.

build_tar(Release=#{name := RelName,
                    vsn := RelVsn}, Apps, State) when is_atom(RelName) ,
                                                      is_list(RelVsn) ->
    %RealizedRelease = build_release_(Release, Apps, State),
    %build_tar_(RealizedRelease, State),
    {ok, State1, RealizedRelease} = build_release_(Release, Apps, State),
	build_tar_(RealizedRelease, State1),
    {ok, RealizedRelease};

After recompiling rebar3, the problem is solved.

@leonlee2007
Copy link
Author

leonlee2007 commented Jun 29, 2022

rebar.config

{erl_opts, [debug_info]}.
{checkouts_dir, "deps"}.
{deps, []}.

{relx, [
        {release, 
         {a, "0.1.0"}, 
         [a, sasl],
         [{overlay, [{copy, "test_data", "test_data"}]}] %overlay does not take effect
        },  
        {release, {b, "0.1.0"}, [b, sasl]},
        {overlay,[ {copy, "test_dir", "test_dir"} ] },
        {dev_mode, true},
        {include_erts, false},
        {extended_start_script, true},
        {sys_config, "./config/sys.config"},
        {vm_args, "./config/vm.args"}
]}.

{profiles, [{prod, [{relx, [{dev_mode, false},
                            {include_erts, false}]}]
            }]  
}.

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

No branches or pull requests

1 participant