Why does Mix output warnings to STDERR?

I’m trying to parse the output of a mix compile run (for use in a text editor linting plugin), and I’ve noticed that all of the output goes to STDOUT except for the warning output, which goes to STDERR.

I’m intrigued to know why this is. I’m going to dive into the Mix source code, but I wanted to post here and see if there was an understood reason that I was missing.

I’m also open to better suggestions for linting that just parsing the human readable compilation output. Would there be a demand for a Mix output format that was more suited to machine reading?



Sounds normal to me, most things output normal ignorable messages to STDOUT and issues that need to be looked at to STDERR?

I could understand that reasoning if compilation errors went to STDERR as well though.

That sounds like a bug then to me. ^.^

I don’t know about that. Let’s look at it from a different perspective.

If I am a CLI of sorts and my main task is to read a file from the internet to the stdio.
If I hit a 404, then I would expect that to be printed to stdio because that was the response.
If I am having problems connecting or if the server isn’t returning any response, then I would expect that to be printed to stderr.

If I am compiling and I get compile errors, then I would say that those are consistent with the same kind of output that I would get from a 404.
If I have deprecation warnings, I would consider those not directly related to the act of compiling.
In other words an error compiling is directly related to the act of compiling and the purpose of the program I started.
Warnings I may get while compiling aren’t directly related to the act of compiling.

Anyway, that’s just my point-of-view. I’m sure that someone could come in and give a completely different point-of-view.

To me STDERR is for exceptional output from the operation, and STDOUT is for regular output from the operation.

My feeling is that warnings are directly related to the act of compiling and thus fall under “regular output from the operation”. On the other hand, if a file that was needed for operation - for example mix.exs - could not be read that would be an “exceptional output from the operation”.

Though as you say @Azolo, everyone has their own point of view on this.

I guess I can always redirect STDERR to STDOUT for this.



1 Like