DioxusLabs/dioxus · error

failed to parse toml at

Error message

failed to parse toml at {}: {}

What it means

Error path in post_create when the freshly generated Cargo.toml or Dioxus.toml of the new project fails to parse with the toml crate. Fires when template serialization produced malformed TOML at the given path — unexpected for a working template, so it usually indicates a corrupted template or a bad write.

Solutions

  1. A TOML file could not be parsed. Fix the TOML syntax at the reported path.
Defensive patterns

Strategy: try-catch

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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

Appendix: source

Thrown at packages/cli/src/cli/create.rs:198

    // 2. Run `cargo fmt` on the new project.
    let mut cmd = Command::new("cargo");
    let cmd = cmd.arg("fmt").current_dir(path);
    let output = cmd.output().expect("failed to execute process");
    if !output.status.success() {
        tracing::error!(dx_src = ?TraceSrc::Dev, "cargo fmt failed");
        tracing::error!(dx_src = ?TraceSrc::Build, "stdout: {}", String::from_utf8_lossy(&output.stdout));
        tracing::error!(dx_src = ?TraceSrc::Build, "stderr: {}", String::from_utf8_lossy(&output.stderr));
    }

    // 3. Format the `Cargo.toml` and `Dioxus.toml` files.
    let toml_paths = [path.join("Cargo.toml"), path.join("Dioxus.toml")];
    for toml_path in &toml_paths {
        let Ok(toml) = std::fs::read_to_string(toml_path) else {
            continue;
        };

        let mut toml = toml.parse::<toml_edit::DocumentMut>().map_err(|e| {
            anyhow::anyhow!("failed to parse toml at {}: {}", toml_path.display(), e)
        })?;

        toml.as_table_mut().fmt();

        let as_string = toml.to_string();
        let new_string = remove_triple_newlines(&as_string);
        let mut file = std::fs::File::create(toml_path)?;
        file.write_all(new_string.as_bytes())?;
    }

    // 4. Remove any triple newlines from the readme.
    let readme_path = path.join("README.md");
    let readme = std::fs::read_to_string(&readme_path)?;
    let new_readme = remove_triple_newlines(&readme);
    let mut file = std::fs::File::create(readme_path)?;
    file.write_all(new_readme.as_bytes())?;

    // 5. Run git init

View on GitHub (pinned to 24f6a829df)