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 ERTS source directory is missing #538

Closed efine closed 7 years ago

efine commented 7 years ago

Note

This was originally opened on rebar3, but moved here at @ferd's suggestion.

Current behaviour

I'm building https://github.com/SilentCircle/scpf.git (tag v2.0.0-alpha) using cowbuilder under Debian jessie. It builds with no problem when I run the build on my development system using either of these commands:

However, when I build it as a debian package on our build system (using cowbuilder), on which the standard Debian Erlang 18.3 gets installed, it fails.

rebar3 seems to be trying to delete the ERTS source tree, which I suspect doesn't exist in the standard Debian installation (it's hard to tell because the build system deletes the build environment right after it finishes). On my development system, I am using the same version of Erlang, but installed using kerl, so the source directory is there.

The line reported in the crash is rlx_prv_assembler.erl:510:

505                     %% delete erts src if the user requested it not be included
506                     case rlx_state:include_src(State) of
507                         true -> ok;
508                         false ->
509                             SrcDir = filename:join([LocalErts, "src"]),
510                             ok = ec_file:remove(SrcDir, [recursive])
511                     end,

Environment

$ ./rebar3 version
rebar 3.3.2 on Erlang/OTP 18 Erts 7.3.1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.6 (jessie)
Release:    8.6
Codename:   jessie

Stack trace

===> Running provider release
===> Including Erts from /usr/lib/erlang
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: {badmatch,{error,enoent}}
===> Stack trace to the error location:
[{rlx_prv_assembler,include_erts,4,
                    [{file,"/home/tristan/Devel/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"},
                     {line,510}]},
 {rlx_prv_assembler,do,1,
                    [{file,"/home/tristan/Devel/rebar3/_build/default/lib/relx/src/rlx_prv_assembler.erl"},
                     {line,59}]},
 {relx,run_provider,2,
       [{file,"/home/tristan/Devel/rebar3/_build/default/lib/relx/src/relx.erl"},
        {line,308}]},
 {lists,foldl,3,[{file,"lists.erl"},{line,1262}]},
 {relx,run_providers_for_actions,2,
       [{file,"/home/tristan/Devel/rebar3/_build/default/lib/relx/src/relx.erl"},
        {line,291}]},
 {relx,main,2,
       [{file,"/home/tristan/Devel/rebar3/_build/default/lib/relx/src/relx.erl"},
        {line,65}]},
 {rebar_relx,do,4,
             [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_relx.erl"},
              {line,38}]},
 {rebar_core,do,2,
             [{file,"/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_core.erl"},
              {line,125}]}]
===> When submitting a bug report, please include the output of `rebar3 report "your command"`

Rebar3 report

 version 3.3.2
 generated at 2016-11-14T22:50:06+00:00
=================
Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any)
-----------------
Task: tar
Entered as:
  tar
-----------------
Operating System: x86_64-pc-linux-gnu
ERTS: Erlang/OTP 18 [erts-7.3.1] [source] [64-bit] [smp:4:4] [async-threads:0] [kernel-poll:false]
Root Directory: /usr/lib/erlang
Library directory: /usr/lib/erlang/lib
-----------------
Loaded Applications:
bbmustache: 1.3.0
certifi: 0.4.0
cf: 0.2.1
common_test: 1.12.1
compiler: 6.0.3
crypto: 3.6.3
cth_readable: 1.2.3
dialyzer: 2.9
edoc: 0.7.18
erlware_commons: 0.21.0
eunit: 2.2.13
eunit_formatters: 0.3.1
getopt: 0.8.2
inets: 6.2.4
kernel: 4.2
providers: 1.6.0
public_key: 1.1.1
relx: 3.21.1
sasl: 2.7
snmp: 5.2.2
ssl_verify_fun: 1.1.1
stdlib: 2.8
syntax_tools: 1.7
tools: 2.8.3

-----------------
Escript path: /tmp/buildd/scpf-2.0.0+0~20161114224926.89+jessie/rebar3
Providers:
  app_discovery as clean compile compile cover ct deps dialyzer do edoc escriptize eunit help install install_deps list lock new path pkgs release relup report shell state tar tree unlock update upgrade upgrade upgrade version xref

Expected behaviour

If this is indeed the issue, my suggestion would be not to make it crash if the directory just doesn't exist in the first place. The code of ec_file:remove/2 seems to return an error in this situation.

efine commented 7 years ago

I found that #525 fixed this issue. However, because v3.21.1 is the last relx release dated October 7, and #525 is later than that, this fix hasn't made it into rebar3 yet. Closing this issue as a duplicate.

lrascao commented 7 years ago

@efine thanks for the detailed report and sorry for the delay, i was about to mention #525 but haven't been able to find the time for it, we'll try and cut a new release with this fix asap