astral-sh/ruff · error

The installed version of uv does not support `uv format`; up

Error message

The installed version of uv does not support `uv format`; upgrade to a newer version

What it means

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.

Source

Thrown at crates/ruff_server/src/format.rs:342

        stdin
            .write_all(source.as_bytes())
            .context("Failed to write to stdin")?;
        drop(stdin);

        let result = child
            .wait_with_output()
            .context("Failed to get output from format subprocess")?;

        if !result.status.success() {
            let stderr = String::from_utf8_lossy(&result.stderr);
            // We don't propagate format errors due to invalid syntax
            if stderr.contains("Failed to parse") {
                tracing::warn!("Unable to format document: {}", stderr);
                return Ok(FormatResult::Unchanged);
            }
            // Special-case for when `uv format` is not available
            if stderr.contains("unrecognized subcommand 'format'") {
                anyhow::bail!(
                    "The installed version of uv does not support `uv format`; upgrade to a newer version"
                );
            }
            anyhow::bail!("Failed to format document: {stderr}");
        }

        let formatted = String::from_utf8(result.stdout)
            .context("Failed to parse stdout from format subprocess as utf-8")?;

        if formatted == source {
            Ok(FormatResult::Unchanged)
        } else {
            Ok(FormatResult::Formatted(formatted))
        }
    }

    /// Format the entire document.
    fn format_document(&self, source: &str, path: &Path) -> crate::Result<FormatResult> {

View on GitHub (pinned to 26f38c119c)

Solutions

  1. Upgrade uv (`uv self update` or reinstall via the official installer)
  2. Remove or deprioritize the old uv on PATH (`which -a uv`, fix order or delete stale binary)
  3. If upgrading is impossible, disable the uv-based formatter path and use another formatter for the server

Example fix

# before
uv --version  # old, lacks `format` subcommand
# after
uv self update && uv --version
Defensive patterns

Strategy: validation

Validate before calling

import subprocess, re
out = subprocess.run(['uv', '--version'], capture_output=True, text=True).stdout
# require a uv new enough to have `uv format`
if not out.startswith('uv '):
    raise SystemExit('uv not installed')

Prevention

When it happens

Trigger: Invoking LSP formatting while an older uv (before `uv format` was added) is the first `uv` on PATH.

Common situations: System package managers shipping old uv versions; PATH resolving to an outdated uv shim; stale uv installed in `~/.local/bin` shadowing a newer one.

Related errors


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/2ce30c640b27c290. Report an issue: GitHub.