DioxusLabs/dioxus · error · anyhow::Error

cargo fmt failed with status: {out:?}

Error message

cargo fmt failed with status: {out:?}

What it means

Raised in indentation_for when the `cargo fmt -- --print-config current` subprocess used to discover rustfmt's configured indentation exits with a non-success status. This is an external tool failure: cargo/rustfmt could not produce the config for the given file or directory (broken toolchain, bad config, or cargo errors), so indentation options cannot be derived.

Source

Thrown at packages/cli/src/cli/autoformat.rs:212

        bail!("{files_formatted} files needed formatting");
    }

    Ok(())
}

fn indentation_for(
    file_or_dir: impl AsRef<Path>,
    split_line_attributes: bool,
) -> Result<IndentOptions> {
    let out = std::process::Command::new("cargo")
        .args(["fmt", "--", "--print-config", "current"])
        .arg(file_or_dir.as_ref())
        .stdout(std::process::Stdio::piped())
        .stderr(std::process::Stdio::inherit())
        .output()?;

    if !out.status.success() {
        bail!("cargo fmt failed with status: {out:?}");
    }

    let config = String::from_utf8_lossy(&out.stdout);

    let hard_tabs = config
        .lines()
        .find(|line| line.starts_with("hard_tabs "))
        .and_then(|line| line.split_once('='))
        .map(|(_, value)| value.trim() == "true")
        .context("Could not find hard_tabs option in rustfmt config")?;
    let tab_spaces = config
        .lines()
        .find(|line| line.starts_with("tab_spaces "))
        .and_then(|line| line.split_once('='))
        .map(|(_, value)| value.trim().parse::<usize>())
        .context("Could not find tab_spaces option in rustfmt config")?
        .context("Could not parse tab_spaces option in rustfmt config")?;

View on GitHub (pinned to 24f6a829df)

Solutions

  1. cargo fmt failed. Fix the syntax errors rustfmt reported in the output.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/cli/src/cli/autoformat.rs:212 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/6aa38ae821072709. Report an issue: GitHub.