erlang / rebar3

Erlang build tool that makes it easy to compile and test Erlang applications and releases.
http://www.rebar3.org
Apache License 2.0
1.69k stars 515 forks source link

Running help with providers that have no options defined causes badmatch error #30

Closed oubiwann closed 9 years ago

oubiwann commented 9 years ago

For instance, running this:

$ DEBUG=1 ./rebar3 help shell

Gives this:

===> Evaluating config script "rebar.config.script"
===> Consult config file "rebar.lock"
Start a shell with project and deps preloaded similar to
'erl -pa ebin -pa deps/*/ebin'.

===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace
===> Uncaught error: {'EXIT',
                                {{badmatch,[]},
                                 [{getopt,usage_cmd_line,3,
                                      [{file,"src/getopt.erl"},{line,588}]},
                                  {getopt,usage,5,
                                      [{file,"src/getopt.erl"},{line,570}]},
                                  {rebar_prv_help,do,1,
                                      [{file,"src/rebar_prv_help.erl"},
                                       {line,48}]},
                                  {providers,run_all,2,
                                      [{file,"src/providers.erl"},{line,82}]},
                                  {rebar_core,do,2,
                                      [{file,"src/rebar_core.erl"},{line,64}]},
                                  {rebar3,main,1,
                                      [{file,"src/rebar3.erl"},{line,46}]},
                                  {escript,run,2,
                                      [{file,"escript.erl"},{line,752}]},
                                  {escript,start,1,
                                      [{file,"escript.erl"},{line,276}]}]}}

I mis-spent a lot of time trying to track this down, thinking it was a bug in my own plugin/providers code.

I'm on my way to a hack-around, but it would be nice if we could save the next contributor an our or so of confusion ;-)

tsloughter commented 9 years ago

Ah, yup, hadn't decided how to handle that. Should it warn, error, ignore, other?

@ferd thoughts?

oubiwann commented 9 years ago

What I would expect is that the usage would be displayed like it is now when options are provided, but without the missing info. For instance, I feel that $ rebar3 help shell should give the following:

Run shell with project apps and deps in path.

Usage: rebar shell

Whereas, when options are provided (e.g., with the help provider):

Display a list of tasks or help for a given task or subtask.

Usage: rebar help [<help_task>]

  <help_task>  Task to print help for.
tsloughter commented 9 years ago

Ooooh, my bad, I completely misunderstood the issue, haha. I'll have this fixed shortly :)

oubiwann commented 9 years ago

More, specific thoughts:

Perhaps this:

{opts, [{undefined, undefined, undefined, undefined, ""}]}

and this:

{opts, []}

should provide the same result?

<long desc>

Usage: rebar <provider name>
tsloughter commented 9 years ago

Doing [{undefined, undefined, undefined, undefined, ""}] won't work. That gives:

Start a shell with project and deps preloaded similar to
'erl -pa ebin -pa deps/*/ebin'.

Usage: rebar shell 

  <undefined>

This may be an annoying limitation of getopt and require just checking if opts is [] and printing out the info manually instead of calling getopt.

tsloughter commented 9 years ago

Pushed to providers. So should work if you delete deps/providers and rebuild.

oubiwann commented 9 years ago

Hrm, didn't work :-/ Does rebar3 cache deps anywhere else?

tsloughter commented 9 years ago

How are you building? If you blow away deps/providers that should be enough. Currently rebar3 is just built by rebar2 :). So I usually just run rebar get-deps compile escriptize.

oubiwann commented 9 years ago

I just did rm -rf deps/providers and then make. I just cd'ed into deps/providers and did a git log -- the last commit was Nov 17. Which leads me to believe ...

Yup, the rebar.config for rebar3 is pointing to a specific branch: format_error1,

tsloughter commented 9 years ago

Ah, my bad, I've been working on a profile feature branch. I'll cherry-pick this fix to format_error1.

Done.

oubiwann commented 9 years ago

Another issue popped up, but first, to put this all in context:

  1. You guys have done an awesome job with rebar3 :-) I'm really liking it. It's one of the best-designed build tool systems I've seen in a while. Maybe ever.
  2. It has been a blast working with you today on this! You've been incredibly helpful -- thanks!
  3. If you have other stuff to do, I hope you don't feel you need to make sure this all gets sorted out now... you've already gone above and beyond :-)

All that's so you have a good idea of where I'm coming from; no gift-horsing here :-) If you do have the time, here's the lastest thing that popped up when I tried to rebuild after removing the providers dep and getting the latest:

==> providers (compile)
Compiling lab/erlang/rebar3/deps/providers/src/providers.erl failed:
 lab/erlang/rebar3/deps/providers/src/providers.erl:191: field profile undefined in record provider
 lab/erlang/rebar3/deps/providers/src/providers.erl:200: field profile undefined in record provider
 lab/erlang/rebar3/deps/providers/src/providers.erl:218: field profile undefined in record provider
 lab/erlang/rebar3/deps/providers/src/providers.erl:216: Warning: variable 'Profile' is unused
ERROR: compile failed while processing lab/erlang/rebar3/deps/providers: rebar_abort

I've already started a new project exploring building providers in native LFE land ... ;-)

tsloughter commented 9 years ago

Oops, I did that too fast and part of the profile feature stuff got committed with it, haha.

The fun with working on a quickly changing alpha code base :)

I just force pushed over that change in format_error1 to remove the profile stuff and fix the help issue.

You can also consider using the profiles branch from tsloughter/rebar3. I've opened a PR for it waiting for review from Fred and others. It is a pretty big change so likely scary bugs, but it'll eventually be master in some form, so may be useful to work from it.

Don't feel like you shouldn't send these, we need them and I'm just sitting around watching college football and working on this :)

Thanks for the kind words! Feel free to also ping me on irc.

oubiwann commented 9 years ago

Perfect! That last one did the trick -- thanks so much :-)

Also: love the profiles branch. I've needed that many times in various LFE projects. Used its counterpart in Clojure a bunch, much to my satisfaction.

Looking forward to it!