[erlang-questions] rebar -- how do I get useful error messages
Jon Watte
jwatte@REDACTED
Mon Dec 5 19:56:54 CET 2011
>
> The reason that the error message only contains the 'src' directory is
> that rebar changes into subdirectories
That's why I think rebar *is* the source of the messages being not-useful
:-)
For now, I'm using a simple Make rule that expresses dependencies between
apps/*/ebin/*.beam and apps/*/src/*.erl, and *.hrl files, using (make)
pattern matching, and calling erlc directly. This gives me usable error
messages.
But I can't believe nobody else already got bitten by this!
I'll go check the rebar community. But having to join and unjoin lists just
for particular errors gets old after a while :-/
Sincerely,
jw
--
Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.
On Sat, Dec 3, 2011 at 7:31 AM, Tim Watson <watson.timothy@REDACTED> wrote:
> On 2 December 2011 22:36, Jon Watte <jwatte@REDACTED> wrote:
>
>> unfortunately, when I do this, the paths that come out of the compiler
>> error messages does not contain the "apps" directory or the name of the
>> actual app. For example, if I have an error in the file
>> "apps/myapp/src/somefile.erl" then the error message will say
>> "src/somefile.erl:44: some error here."
>> THIS, in turn, breaks the go-to-compile-error logic for the editor -- it
>> cannot find the file in question. I can string-substitute the output of
>> rebar to tack on "apps/" in front, but without the actual application,
>> that's not good enough, and I don't easily know which app name to also tack
>> on.
>>
>> So -- how do you guys solve this? Jumping to compile errors in the editor
>> is one of those basics that nobody really wants to live without, so I can't
>> imagine that an entire community is living without...
>>
>>
> I think rebar is not the source of the shortened error message here,
> but rather the error message is being generated by the `compile' module
> itself. The rebar_erlc_compiler does pass on the 'report' option to
> compile:file/2, but this just prints out warnings and errors. The reason
> that the error message only contains the 'src' directory is that rebar
> changes into subdirectories (using file:set_cwd/1) before processing them.
> If you wanted to annotate the errors, you'd need to patch
> rebar_erlc_compiler and do something like:
>
> case compile:file(Source, [return_errors|Opts]) of
> {ok, _} -> ok;
> {error, Errors, _} ->
> [ ?ERROR("~s: ~s", [filename:absname(File),
> compile:format_error(Err)]) || {F, Err} <- Errors ],
> ?ABORT("Compilation failed!~n", [])
> end;
>
> The place you'd need to make that change is here:
> https://github.com/basho/rebar/blob/master/src/rebar_erlc_compiler.erl#L258
>
> HTH. BTW I have no idea whether or not this would make it into rebar, nor
> if it's even the best approach. There may be far better ways of doing this,
> so I'd suggest discussion on the rebar mailing list as a next step, unless
> you're happy maintaining your own fork.
>
> Cheers,
>
> Tim
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111205/61003437/attachment.htm>
More information about the erlang-questions
mailing list