numtide / treefmt

one CLI to format your repo
https://treefmt.com
MIT License
534 stars 32 forks source link

what does "One or more formatters are missing" mean? #286

Open MangoIV opened 2 months ago

MangoIV commented 2 months ago

Describe the bug

I'm trying to run selected formatters of the ones declared in my treefmt.toml, I get "One or more formatters missing"

To Reproduce

following treefmt.toml

[formatter.nix]
command = "nixpkgs-fmt"
includes = ["*.nix"]
excludes = [ "nix/sources.nix"] # managed by niv. 

[formatter.cabal-fmt]
command = "cabal-fmt"
options = [ "--inplace" ]
includes = [ "*.cabal" ]
excludes = [ "dist-newstyle/" ]

[formatter.ormolu]
command = "ormolu"
includes = ["*.hs"]
excludes = [ "dist*" ]
options = [
  "--mode", "inplace", 
  "--check-idempotence",
]

[formatter.hlint]
command = "hlint"
includes = ["*.hs"]
excludes = [ "dist*" ]

[formatter.shellcheck]
command = "shellcheck"
includes = ["*.sh"]
excludes = []

Steps to reproduce the behavior:

run treefmt -v -f cabal-fmt, get [ERROR] One or more formatters are missing what does this mean? I want to only run cabal-fmt; there's a formatter in the toml that is called that and cabal-fmt is available.

Expected behavior

it runs only the cabal-fmt formatter

System information

treefmt version 0.6.1, nixos nixpkgs unstable

Additional context n/a

MangoIV commented 2 months ago

The issue here is that I don't even understand what the error message is supposed to tell me, does it think the formatter is missing in the path? Does it mean that the formatter is missing in the toml? according to the Debug log, it does parse the config file and it is able to format the repo without passing arguments.

MangoIV commented 2 months ago

alright; I have found the option --allow-missing-formatter which makes it run even with multiple argument but it seems like it invalidates the cache of the run without specific formatters which makes it practically unusable? I also don't know what exactly is the problem here; why does it need to have this flag passed?

MangoIV commented 2 months ago

yeah; so by using treefmt --allow-missing-formatter -f cabal-fmt -f ormolu -f hlint I get cache misses on the formatters that I have not specified via the f flag on the next run.