rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

Fail loudly on error when executing a cmd in an app.src vsn

Open aronisstav opened this issue 3 years ago • 1 comments

This PR fixes a bug.

Description When running rebar3 compile on a strange environment (Windows...), a cmd command in a vsn attribute in an .app.src file failed.

Expected behaviour An error is prominently displayed.

Actual behaviour The error was only available with DEBUG=1 and localizing it to the vsn attribute took quite some further digging.

Additional info While at it, make it so that {abort_on_error, Msg} ALSO shows the error that generated it, indiscriminately. This is a little breaking, but should be a good thing.

I think that this PR is good enough as-is. I might have time to also add a test, if someone kindly points out specifically where.

aronisstav avatar Apr 22 '21 13:04 aronisstav

Can you show the expected difference between the old output and the new one? I'm having a bit of a hard time just tracing in my mind what the difference in output is expected to look like.

Right, I forgot!

Before:

❯ cat src/foo.app.src                    
{application, foo,
 [{description, "An OTP application"},
  {vsn, {cmd, "false"}},
  {registered, []},
  {mod, {foo_app, []}},
  {applications,
   [kernel,
    stdlib
   ]},
  {env,[]},
  {modules, []},

  {licenses, ["Apache 2.0"]},
  {links, []}
 ]}.


❯ rebar3 compile                                   
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling foo

❯ echo $?                                             
1

❯ DEBUG=1 rebar3 compile                                 
===> Expanded command sequence to be run: [app_discovery,install_deps,lock,compile]
===> Running provider: app_discovery
===> Found top-level apps: [foo]
	using config: [{src_dirs,["src"]},{lib_dirs,["apps/*","lib/*","."]}]
===> Running provider: install_deps
===> Verifying dependencies...
===> Running provider: lock
===> Running provider: compile
===> Compile (apps)
===> Running hooks for compile with configuration:
===> 	{pre_hooks, []}.
===> Compile (project_apps)
===> Running hooks for compile in app foo (/Users/stavros/sandbox/foo) with configuration:
===> 	{pre_hooks, []}.
===> Running hooks for erlc_compile in app foo (/Users/stavros/sandbox/foo) with configuration:
===> 	{pre_hooks, []}.
===> Analyzing applications...
===> Compiling foo
===> compile options: {erl_opts, [debug_info]}.
===> files to analyze ["/Users/stavros/sandbox/foo/src/foo_sup.erl",
                              "/Users/stavros/sandbox/foo/src/foo_app.erl"]
===> Running hooks for erlc_compile in app foo (/Users/stavros/sandbox/foo) with configuration:
===> 	{post_hooks, []}.
===> Running hooks for app_compile in app foo (/Users/stavros/sandbox/foo) with configuration:
===> 	{pre_hooks, []}.
===> sh(false)
failed with return code 1 and the following output:

After:

❯ rebar3 compile                           
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling foo
===> vsn cmd in .app.src failed
sh(false)
failed with return code 1 and the following output:

aronisstav avatar Apr 22 '21 15:04 aronisstav