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

Error log not initialized when loading ~/.config/rebar3/rebar.config #1792

Closed
peterzeller opened this issue May 28, 2018 · 1 comment
Closed
Labels
enhancement new behaviour or additional functionality minor bug bug that does not prevent major features from working

Comments

@peterzeller
Copy link

When there is a syntax error in ~/.config/rebar3/rebar.config, rebar3 crashes before the log is initialized, so as a user I only see a stack trace pointing to the log function.

As an example, I had {plugins, [{rebar3_proper, 0.9.0}]}. in my config file (missed the quotes).

I could submit a pull request with a fallback to io:format if the log is not initialized.

Environment

  • Add the result of rebar3 report to your message:
$ rebar3 report compile
escript: exception error: no match of right hand side value undefined
  in function  rebar_log:log/3 (/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar_log.erl, line 96)
  in call from rebar3:handle_error/1 (/home/tristan/Devel/rebar3/_build/default/lib/rebar/src/rebar3.erl, line 314)
  in call from escript:run/2 (escript.erl, line 757)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_em/1 
  in call from init:do_boot/3 

Without the crash (correct rebar.config)

$ rebar3 report compile
Rebar3 report
 version 3.5.0
 generated at 2018-05-28T16:27:11+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: compile
Entered as:
  compile
-----------------
Operating System: x86_64-unknown-linux-gnu
ERTS: Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Root Directory: /home/peter/apps/erlang/19.1
Library directory: /home/peter/apps/erlang/19.1/lib
-----------------
Loaded Applications:
bbmustache: 1.3.0
certifi: 2.0.0
cf: 0.2.2
common_test: 1.12.3
compiler: 7.0.2
crypto: 3.7.1
cth_readable: 1.3.2
dialyzer: 3.0.2
edoc: 0.8
erlware_commons: 1.0.4
eunit: 2.3.1
eunit_formatters: 0.5.0
getopt: 1.0.1
inets: 6.3.3
kernel: 5.1
providers: 1.7.0
public_key: 1.2
relx: 3.24.3
sasl: 3.0.1
snmp: 5.2.4
ssl_verify_fun: 1.1.3
stdlib: 3.1
syntax_tools: 2.1
tools: 2.8.6

-----------------
Escript path: /home/peter/bin/rebar3
Providers:
  app_discovery as clean compile compile cover ct deps dialyzer do edoc escriptize eunit get-deps help install install_deps list lock new path pkgs proper release relup report shell state tar tree unlock update upgrade upgrade upgrade version xref 
@ferd
Copy link
Collaborator

ferd commented May 28, 2018

That could be interesting. I don't see a big downside to it since it seems that it would at least allow the right error message to be output.

Maybe the io:format should mention something like io:format("fallback log: ~ts~n", [Str]) so we can at least find where things have been going wrong

@ferd ferd added enhancement new behaviour or additional functionality minor bug bug that does not prevent major features from working labels Aug 30, 2018
ferd added a commit to ferd/rebar3 that referenced this issue Oct 20, 2018
In some cases, such as when the global rebar.config file contains typoes
and invalid terms, the rebar3 executable fails when trying to log the
error since it hasn't been set yet, such as in erlang#1792

This patch fixes that by going for a fallback mechanism.
@ferd ferd closed this as completed Feb 1, 2019
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 minor bug bug that does not prevent major features from working
Projects
None yet
Development

No branches or pull requests

2 participants