{"record":{"id":"2ce30c640b27c290","repo":"astral-sh/ruff","slug":"the-installed-version-of-uv-does-not-support-uv-f","errorCode":null,"errorMessage":"The installed version of uv does not support `uv format`; upgrade to a newer version","messagePattern":"The installed version of uv does not support `uv format`; upgrade to a newer version","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_server/src/format.rs","lineNumber":342,"sourceCode":"        stdin\n            .write_all(source.as_bytes())\n            .context(\"Failed to write to stdin\")?;\n        drop(stdin);\n\n        let result = child\n            .wait_with_output()\n            .context(\"Failed to get output from format subprocess\")?;\n\n        if !result.status.success() {\n            let stderr = String::from_utf8_lossy(&result.stderr);\n            // We don't propagate format errors due to invalid syntax\n            if stderr.contains(\"Failed to parse\") {\n                tracing::warn!(\"Unable to format document: {}\", stderr);\n                return Ok(FormatResult::Unchanged);\n            }\n            // Special-case for when `uv format` is not available\n            if stderr.contains(\"unrecognized subcommand 'format'\") {\n                anyhow::bail!(\n                    \"The installed version of uv does not support `uv format`; upgrade to a newer version\"\n                );\n            }\n            anyhow::bail!(\"Failed to format document: {stderr}\");\n        }\n\n        let formatted = String::from_utf8(result.stdout)\n            .context(\"Failed to parse stdout from format subprocess as utf-8\")?;\n\n        if formatted == source {\n            Ok(FormatResult::Unchanged)\n        } else {\n            Ok(FormatResult::Formatted(formatted))\n        }\n    }\n\n    /// Format the entire document.\n    fn format_document(&self, source: &str, path: &Path) -> crate::Result<FormatResult> {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_server/src/format.rs#L324-L360","documentation":"The server runs `uv format` and inspects stderr; if uv responds with \"unrecognized subcommand 'format'\", the installed uv predates the `uv format` subcommand. The server surfaces a targeted anyhow error advising an upgrade rather than a generic format failure.","triggerScenarios":"Invoking LSP formatting while an older uv (before `uv format` was added) is the first `uv` on PATH.","commonSituations":"System package managers shipping old uv versions; PATH resolving to an outdated uv shim; stale uv installed in `~/.local/bin` shadowing a newer one.","solutions":["Upgrade uv (`uv self update` or reinstall via the official installer)","Remove or deprioritize the old uv on PATH (`which -a uv`, fix order or delete stale binary)","If upgrading is impossible, disable the uv-based formatter path and use another formatter for the server"],"exampleFix":"# before\nuv --version  # old, lacks `format` subcommand\n# after\nuv self update && uv --version","handlingStrategy":"validation","validationCode":"import subprocess, re\nout = subprocess.run(['uv', '--version'], capture_output=True, text=True).stdout\n# require a uv new enough to have `uv format`\nif not out.startswith('uv '):\n    raise SystemExit('uv not installed')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep uv up to date (`uv self update`)","Avoid old distro-packaged uv builds; use the official installer","Check `uv format --help` succeeds before enabling the formatter in the server"],"tags":["ruff","lsp","formatting","uv","version"],"backgroundTag":"unsupported-tool-version","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}