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

Plug-ins with errors in .app file "not available" #1877

Closed
eproxus opened this issue Sep 10, 2018 · 9 comments · Fixed by #2316
Closed

Plug-ins with errors in .app file "not available" #1877

eproxus opened this issue Sep 10, 2018 · 9 comments · Fixed by #2316
Labels
enhancement new behaviour or additional functionality

Comments

@eproxus
Copy link
Contributor

eproxus commented Sep 10, 2018

Environment

$ rebar3 report "version"
===> Compiling rebar3_grisp
===> Plugin rebar3_grisp not available. It will not be used.
Rebar3 report
 version 3.6.1
 generated at 2018-09-10T12:17:14+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: version
Entered as:
  version
-----------------
Operating System: x86_64-apple-darwin17.7.0
ERTS: Erlang/OTP 21 [erts-10.0.7] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Root Directory: /Users/user/.asdf/installs/erlang/21.0.8
Library directory: /Users/user/.asdf/installs/erlang/21.0.8/lib
-----------------
Loaded Applications:
bbmustache: 1.5.0
certifi: 2.0.0
cf: 0.2.2
common_test: 1.16
compiler: 7.2.3
crypto: 4.3.2
cth_readable: 1.4.2
dialyzer: 3.3
edoc: 0.9.3
erlware_commons: 1.2.0
eunit: 2.3.6
eunit_formatters: 0.5.0
getopt: 1.0.1
hipe: 3.18
inets: 7.0.1
kernel: 6.0.1
providers: 1.7.0
public_key: 1.6.1
relx: 3.26.0
sasl: 3.2
snmp: 5.2.11
ssl_verify_fun: 1.1.3
stdlib: 3.5.1
syntax_tools: 2.1.5
tools: 3.0

-----------------
Escript path: undefined
Providers:
  app_discovery as auto clean compile compile config cover ct cut deps dialyzer do docs edoc escriptize eunit get-deps help info install install_deps key list lock new owner path pkgs publish release relup report search shell state tar tree unlock update upgrade upgrade upgrade user version xref

Current behaviour

Describe the current behaviour. In case of a failure, crash, or exception, please include the result of running the command with debug information:

$ DEBUG=1 rebar3 version
===> Load global config file /Users/user/.config/rebar3/rebar.config
===> Compiling rebar3_grisp
===> run_hooks("/Users/user/Code/robot/_checkouts/rebar3_grisp", pre_hooks, compile) -> no hooks defined

===> run_hooks("/Users/user/Code/robot/_checkouts/rebar3_grisp", pre_hooks, erlc_compile) -> no hooks defined

===> erlopts [debug_info]
===> files to compile ["/Users/user/Code/robot/_checkouts/rebar3_grisp/src/rebar3_grisp_util.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/rebar3_grisp_deploy.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/rebar3_grisp.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/grisp_tools_handler.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/rebar3_grisp_version.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/grisp_tools.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/rebar3_grisp_build.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/grisp_tools_deploy.erl",
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/grisp_tools_util.erl"]
===>      Compiled grisp_tools_util.erl
===>      Compiled grisp_tools_deploy.erl
===> run_hooks("/Users/user/Code/robot/_checkouts/rebar3_grisp", post_hooks, erlc_compile) -> no hooks defined

===> run_hooks("/Users/user/Code/robot/_checkouts/rebar3_grisp", pre_hooks, app_compile) -> no hooks defined

===> throw {error,
                      {rebar_file_utils,
                          {bad_term_file,
                              "/Users/user/Code/robot/_checkouts/rebar3_grisp/src/rebar3_grisp.app.src",
                              {14,erl_parse,
                               ["syntax error before: ","']'"]}}}} [{rebar_file_utils,
                                                                     try_consult,
                                                                     1,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_file_utils.erl"},
                                                                      {line,
                                                                       65}]},
                                                                    {rebar_otp_app,
                                                                     consult_app_file,
                                                                     1,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_otp_app.erl"},
                                                                      {line,
                                                                       225}]},
                                                                    {rebar_otp_app,
                                                                     preprocess,
                                                                     3,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_otp_app.erl"},
                                                                      {line,
                                                                       103}]},
                                                                    {rebar_otp_app,
                                                                     compile,
                                                                     2,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_otp_app.erl"},
                                                                      {line,
                                                                       49}]},
                                                                    {rebar_prv_compile,
                                                                     compile,
                                                                     3,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_prv_compile.erl"},
                                                                      {line,
                                                                       146}]},
                                                                    {rebar_plugins,
                                                                     '-handle_plugin/4-lc$^1/1-1-',
                                                                     3,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_plugins.erl"},
                                                                      {line,
                                                                       103}]},
                                                                    {rebar_plugins,
                                                                     handle_plugin,
                                                                     4,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_plugins.erl"},
                                                                      {line,
                                                                       103}]},
                                                                    {rebar_plugins,
                                                                     '-handle_plugins/4-fun-0-',
                                                                     4,
                                                                     [{file,
                                                                       "/home/tristan/Devel/rebar3/_build/prod/lib/rebar/src/rebar_plugins.erl"},
                                                                      {line,
                                                                       83}]}]
===> Plugin rebar3_grisp not available. It will not be used.
===> Expanded command sequence to be run: [{default,version}]
===> Provider: {default,version}
rebar 3.6.1 on Erlang/OTP 21 Erts 10.0.7

Expected behaviour

An error saying not that the plug-in is "unavailable" but that there was problems running/compiling the plug-in so I know what debug next. E.g. (in red):

===> Errors loading plugin rebar3_grisp. Use DEBUG=1 to see errors.
@ferd
Copy link
Collaborator

ferd commented Sep 10, 2018

Yeah that would be a fair change. Initially, the message was added that way because rebar 2.x only allowed a module name as a plugin (and expected it to have been specified in deps). When we supported packages as plugins in the same {plugins, List} field, we had no way to know if a plugin entry referred to a module from 2.x (especially in deps) or to a package that we wanted to fetch.

As such, there is a step where we flat out try to load the module, and just show a little advice saying "plugins is not available" since it was possibly normal to see a bunch of skipped plugins, especially when a bunch of them might have been related to tests or non-dep build tasks.

As the ecosystem shifted and that pure rebar 2.x dependencies (that also requited non-critical plugins) became rarer, it would probably make sense to revisit the errors displayed today since they're not as likely to be due for the same reason anymore.

@ferd ferd added the enhancement new behaviour or additional functionality label Sep 10, 2018
@eproxus
Copy link
Contributor Author

eproxus commented Sep 10, 2018

Thanks for the explanation. It's a minor nitpicking issue, but I found the message misleading and spent some time debugging paths before I realized there was just an error in the .app-file 😉

@ferd
Copy link
Collaborator

ferd commented Sep 10, 2018

?WARN("Plugin ~p not available. It will not be used.", [Plugin]),
seems like the only line that would need to change. If you'd like to pick the sentence to put in there, it would probably be a quick merge :)

@tsloughter
Copy link
Collaborator

It was added for 2 reasons.

The second was that, at least for me, I too often had a whole build fail in rebar2 because a plugin that was unrelated to the build failed to be fetched or compile. It was ridiculous to fail compiling because a plugin that wouldn't even be used during compilation failed.

So the idea was to try to still build and not let developers who put unnecessary plugins in the main plugin list to be a blocker.

It may be the case that now with profiles this isn't as necessary. test plugins and doc plugins go in those profiles. But it isn't prefect since, for example, you can't put a plugin in the test profile and be able to run it without rebar3 as test which people don't like.

So I'm a little skeptical about dropping this but I'm open to it.

@lrascao
Copy link
Contributor

lrascao commented Sep 10, 2018

maybe not fail the whole build but just add visibility to the fact that the plugin is broken is sufficient for OP

@tsloughter
Copy link
Collaborator

That was the purpose of the warning :)

@ferd
Copy link
Collaborator

ferd commented Sep 10, 2018

yeah. Pointing at least to DEBUG=1 should reveal the error. A plugin breaking nowadays is probably worse than a plugin breaking back then, and pointing the user to a debug or escalation path would probably make sense as opposed to just silently going "heh nope that won't do"

@eproxus
Copy link
Contributor Author

eproxus commented Sep 11, 2018

I'd be happy if the warning was just "There was a problem loading the plugin XYZ" instead of being misleading. 🙂 I guess the amount of people running broken plugins is smaller than the amount of people wanting errors for them (although I wouldn't mind Rebar erroring out here since I would never personally just add a broken plugin and go about my day. I'd rather have Rebar point that out).

@tsloughter
Copy link
Collaborator

I'm messing around with plugins and ran into this old issue. I think we were all in agreement so I'll change the warning message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new behaviour or additional functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants