taplo icon indicating copy to clipboard operation
taplo copied to clipboard

`taplo fmt --check -diff` false positive on windows

Open tamird opened this issue 8 months ago • 4 comments

Run taplo fmt --check --diff
  taplo fmt --check --diff
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    CARGO_HOME: C:\Users\runneradmin/.cargo
    CARGO_INCREMENTAL: 0
    CARGO_TERM_COLOR: always
    CACHE_ON_FAILURE: false
 INFO taplo:format_files:collect_files: found files total=[3](https://github.com/jmgao/pore/actions/runs/14044977210/job/39323643851#step:6:3) excluded=0 cwd="D:/a/pore/pore"
diff a/D:/a/pore/pore/.rustfmt.toml b/D:/a/pore/pore/.rustfmt.toml
--- a/D:/a/pore/pore/.rustfmt.toml
+++ b/D:/a/pore/pore/.rustfmt.toml
@@ -0,0 +0,0 @@

ERROR taplo:format_files: the file is not properly formatted path="D:/a/pore/pore/.rustfmt.toml"
diff a/D:/a/pore/pore/Cargo.toml b/D:/a/pore/pore/Cargo.toml
--- a/D:/a/pore/pore/Cargo.toml
+++ b/D:/a/pore/pore/Cargo.toml
@@ -0,0 +0,0 @@

ERROR taplo:format_files: the file is not properly formatted path="D:/a/pore/pore/Cargo.toml"
diff a/D:/a/pore/pore/pore.toml b/D:/a/pore/pore/pore.toml
--- a/D:/a/pore/pore/pore.toml
+++ b/D:/a/pore/pore/pore.toml
@@ -0,0 +0,0 @@
ERROR taplo:format_files: the file is not properly formatted path="D:/a/pore/pore/pore.toml"

Seen in https://github.com/jmgao/pore/actions/runs/14044977210/job/39323643851. The same check on macOS and Ubuntu exits clean.

tamird avatar Mar 24 '25 20:03 tamird

@tamird, I'm experiencing the same. It seems to be that taplo formats the toml file with LF line endings, while the original is with CRLF. Thus, it will always differ in whitespaces.

psandana avatar May 05 '25 19:05 psandana

Have you tried crlf setting? https://taplo.tamasfe.dev/configuration/formatter-options.html

panekj avatar May 05 '25 20:05 panekj

Have you tried crlf setting? https://taplo.tamasfe.dev/configuration/formatter-options.html

Tried this in a .taplo.toml file:

[formatting]
crlf = true

But still failing. Enabling verbose logging does not give any hints.

psandana avatar May 05 '25 20:05 psandana

After some back and forth, I didn't noticed that taplo converted my files to LF first, thus continued failing. After transforming the .toml files from LF to CRLF, taplo run worked!

Thanks! This is indeed an improvement. Still, I think this should be automatic. For instance, git can be configured to checkout local but commit LF, which may cause pipelines to fail. Same for other CVS.

Would you consider this issue as a feature request to add automatic line-ending detection?

psandana avatar May 06 '25 16:05 psandana