treefmt icon indicating copy to clipboard operation
treefmt copied to clipboard

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

Open MangoIV opened this issue 1 year ago • 3 comments

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 avatar Apr 29 '24 10:04 MangoIV

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 avatar Apr 29 '24 10:04 MangoIV

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 avatar Apr 29 '24 10:04 MangoIV

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.

MangoIV avatar Apr 29 '24 11:04 MangoIV