Closed fklement closed 6 years ago
Does it work if you run “mix format” from your project root? I.e. from the same directory where .formatter.exs is placed? --
José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D
I tried. But nothing happens at all.
It doesn’t happen because the code is already formatted? If you add “foo 1, 2” to a file that is listed, does it add parens? --
José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D
If that still does not work, can you please provide an application that reproduces the issue? We know for certain that it works on windows so we need more information to effectively reproduce this. Thank you! --
José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D
Ping!
I will go ahead and close this for now. We will gladly reopen once we have a mechanism to reproduce the issue.
I have some problem that might be related
~\my_proj [master ↑3 +8 ~8 -0 !] [Aug-24 16:58:04]
> mix format .\lib\app\flow\update_stock_check.ex
** (Mix) Could not find a file to format. The files/patterns given to command line did not point to any existing file. Got: [".\\lib\\app\\flow\\update_stock_check.ex"]
~\my_proj [master ↑3 +8 ~8 -0 !] [Aug-24 16:58:29]
> mix format ./lib/app/flow/update_stock_check.ex
~\my_proj [master ↑3 +8 ~8 -0 !] [Aug-24 16:58:50]
> elixir --version
Erlang/OTP 21 [erts-10.0.1] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
Elixir 1.7.1 (compiled with Erlang/OTP 19)
Notice how the windows \
separated path does not work,
even though File.exists ".\\lib\\app\\flow\\update_stock_check.ex"
returns true
After changing them to /
it worked.
Looks like it's caused by Path.wildcard
returning empty list for the windows path
iex(2)> Path.wildcard(".\\lib\\app\\flow\\update_stock_check.ex")
[]
https://github.com/elixir-lang/elixir/blob/master/lib/mix/lib/mix/tasks/format.ex#L334
@princemaple good find. What is your OTP version? It may be worth checking if OTP 20 and OTP 21 behave the same. Also, are you running on the Windows terminal? Or cygwin or the Ubuntu thingy?
Thanks for the quick reply, @josevalim . I'm on PowerShell & OTP21, it's installed via Chocolatey. I don't have an easy way to install an OTP20 version... I normally dev in docker so it's not a problem for me. I found out about this because I use a build system in Sublime to call formatter, which calls the Elixir on Windows, not the Elixir in docker.
https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/path.ex#L650 @josevalim Looks like this is documented:
Directory separators must always be written as /, even on Windows.
@josevalim I guess Path.wildcard
behaves as expected, according to the above. And mix format
probably needs to do some unification before passing paths to Path.wildcard..?
Environment
Current behavior
In our project the
.formatter.exs
looks like this:The problem is, that the list get's correctly returned but it does not affect the formatted code when i hit save.
Expected behavior
For example:
embeds_one :rates, Type.Rates
becomesembeds_one(:rates, Types.Rates)
which should not be.My colleague is using MacOS and here works everyting fine.