Hello,
When I'm using mix format - to format code from stdin. If dependencies needs to be compiled, the compilation output is written to stdout alongside the formatted code.
This problem is very visible with editor integrations that relies on piping the output back into the file that's to be formatted (I'm using apheleia for Emacs.), and only expects the formatted code on stdout.
I'm not quite sure if this really is a Mix issue or editor formatting system issue, but I suspect that apheleia is not the only formatter that relies on pipes for getting the formatted code.
Elixir and Erlang/OTP versions
Elixir version
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
Elixir 1.19.4 (compiled with Erlang/OTP 28)
Operating system
macOS Tahoe 26.4 (25E246)
Current behavior
Steps to reproduce
mix phx.new foobar
cd foobar
mix deps.get
echo 'defmodule Test do end' | mix format -
...
1> Generated phoenix_live_reload app
3> Generated ecto_sql app
4> ==> swoosh
4> Compiling 59 files (.ex)
4> Generated swoosh app
2> Generated phoenix_live_view app
2> ==> phoenix_live_dashboard
2> Compiling 36 files (.ex)
2> Generated phoenix_live_dashboard app
defmodule Test do
end
- Compilation messages appears on both
stdiout and stderr
stdout contains both compilation output + the formatted code
- Makes it very hard to use piping for integrating with editors
Expected behavior
I'm not sure what the correct solution is, but maybe compilation messages could go only on stderr while the formatted code goes to stdout?
Another solution could be to add a flag to the format task that suppress all messages except the formatted code.
Hello,
When I'm using
mix format -to format code from stdin. If dependencies needs to be compiled, the compilation output is written to stdout alongside the formatted code.This problem is very visible with editor integrations that relies on piping the output back into the file that's to be formatted (I'm using apheleia for Emacs.), and only expects the formatted code on stdout.
I'm not quite sure if this really is a Mix issue or editor formatting system issue, but I suspect that apheleia is not the only formatter that relies on pipes for getting the formatted code.
Elixir and Erlang/OTP versions
Elixir version
Operating system
macOS Tahoe 26.4 (25E246)
Current behavior
Steps to reproduce
stdioutandstderrstdoutcontains both compilation output + the formatted codeExpected behavior
I'm not sure what the correct solution is, but maybe compilation messages could go only on
stderrwhile the formatted code goes tostdout?Another solution could be to add a flag to the format task that suppress all messages except the formatted code.