{"record":{"id":"7f1f6d1ec7e34e7c","repo":"jdx/mise","slug":"following-config-files-are-not-properly-formatted","errorCode":null,"errorMessage":"Following config files are not properly formatted:\n{}","messagePattern":"Following config files are not properly formatted:\n(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/fmt.rs","lineNumber":73,"sourceCode":"                .is_some_and(|f| f.to_string_lossy().ends_with(\"toml\"))\n            {\n                continue;\n            }\n            let source = file::read_to_string(&p)?;\n            let toml = source.clone();\n            let toml = sort(toml)?;\n            let toml = format(toml)?;\n            if self.check {\n                if source != toml {\n                    errors.push(p.display().to_string());\n                }\n                continue;\n            }\n            file::write(&p, &toml)?;\n        }\n\n        if !errors.is_empty() {\n            bail!(\n                \"Following config files are not properly formatted:\\n{}\",\n                errors.join(\"\\n\")\n            );\n        }\n\n        Ok(())\n    }\n}\n\nfn sort(toml: String) -> Result<String> {\n    let mut doc: toml_edit::DocumentMut = toml.parse()?;\n    let order = |k: String| match k.as_str() {\n        \"min_version\" => 0,\n        \"env_file\" => 1,\n        \"env_path\" => 2,\n        \"_\" => 3,\n        \"env\" => 4,\n        \"vars\" => 5,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/cli/fmt.rs#L55-L91","documentation":"`mise fmt --check` reformats each config in memory (custom key sorting via toml_edit plus taplo formatting) and compares it to what is on disk; every file whose canonical form differs is listed and the command exits non-zero without writing anything. It is mise's format-check gate for CI and pre-commit.","triggerScenarios":"Running `mise fmt --check` on configs that were hand-edited, merged, or emitted by a generator with non-canonical key order or spacing.","commonSituations":"A teammate merges mise.toml changes without running fmt locally; CI added the check before contributors got the pre-commit hook; config generated by a script with unsorted keys.","solutions":["Run `mise fmt` (no --check) to rewrite the listed files into canonical form, then commit","Pipe generated configs through `mise fmt --stdin` inside your generator so they are born canonical","Install the project's pre-commit hook (hk/mise fmt) so the check can never see unformatted files","In CI, show the diff on failure (`git diff` after a fixing `mise fmt` run) to speed up review"],"exampleFix":"# before (CI)\n- run: mise fmt --check   # fails, lists mise.toml\n\n# after (developer machine)\nmise fmt\ngit commit -am \"style: mise fmt\"","handlingStrategy":"validation","validationCode":"#!/bin/bash\n# canonicalize first so the check is a pure gate\nmise fmt\nmise fmt --check","typeGuard":null,"tryCatchPattern":"if ! mise fmt --check; then\n  echo 'configs need formatting — run `mise fmt` and commit' >&2\n  mise fmt\n  git diff --stat -- '*mise*.toml'\n  exit 1\nfi","preventionTips":["Wire `mise fmt` into the pre-commit hook so unformatted configs never reach the --check gate","Emit generated configs through `mise fmt --stdin` so they are canonical at creation","Keep the fmt check in CI but document the one-command fix in the failure message"],"tags":["mise","fmt","check","ci","toml","formatting"],"backgroundTag":"format-check-failed","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}