erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
697 stars 232 forks source link

Crash when copy directive in overlay section is malformed #867

Closed SebCav closed 2 years ago

SebCav commented 3 years ago

Hi, rebar3 crashes with "uncaught error in rebar.code" triggered by relx when an overlay contains something like {copy, "<path1> <path2>"} instead of {copy, "<path1>", "<path2">}. A nice error would ease debugging when this thing happens...

sg2342 commented 2 years ago

I looked into this and while turning the crash into a useful error message is easy (just append a catch_all clause to rlx_overlay:do_individual_overlay/4), it turns out that getting the error message to the console (and failing the release task) is harder.

code in relx:build_release_/3 (which is the only consumer of overlay functionality) ignores errors returned by rlx_overlay:render/2.

As a result anything that goes wrong in the overlay task but does not result in a crash fails silently.

sg2342 commented 2 years ago

with #916 merged, the command sequence

rebar3 new release foo; cd foo
sed -i.bak 's/%% use minimal mode to exclude ERTS/\,{overlay, [this_is_a_malformed_entry]}/' rebar.config
rebar3 as prod release

results in

===> Verifying dependencies...
===> Analyzing applications...
===> Compiling foo
===> Assembling release foo-0.1.0...
===> Release successfully assembled: _build/prod/rel/foo
===> Overlay section malformed: this_is_a_malformed_entry
SebCav commented 2 years ago

Great work, thank you!