{"record":{"id":"4797b94e364ee152","repo":"DioxusLabs/dioxus","slug":"failed-to-parse-toml-at","errorCode":null,"errorMessage":"failed to parse toml at {}: {}","messagePattern":"failed to parse toml at (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/cli/create.rs","lineNumber":198,"sourceCode":"    // 2. Run `cargo fmt` on the new project.\n    let mut cmd = Command::new(\"cargo\");\n    let cmd = cmd.arg(\"fmt\").current_dir(path);\n    let output = cmd.output().expect(\"failed to execute process\");\n    if !output.status.success() {\n        tracing::error!(dx_src = ?TraceSrc::Dev, \"cargo fmt failed\");\n        tracing::error!(dx_src = ?TraceSrc::Build, \"stdout: {}\", String::from_utf8_lossy(&output.stdout));\n        tracing::error!(dx_src = ?TraceSrc::Build, \"stderr: {}\", String::from_utf8_lossy(&output.stderr));\n    }\n\n    // 3. Format the `Cargo.toml` and `Dioxus.toml` files.\n    let toml_paths = [path.join(\"Cargo.toml\"), path.join(\"Dioxus.toml\")];\n    for toml_path in &toml_paths {\n        let Ok(toml) = std::fs::read_to_string(toml_path) else {\n            continue;\n        };\n\n        let mut toml = toml.parse::<toml_edit::DocumentMut>().map_err(|e| {\n            anyhow::anyhow!(\"failed to parse toml at {}: {}\", toml_path.display(), e)\n        })?;\n\n        toml.as_table_mut().fmt();\n\n        let as_string = toml.to_string();\n        let new_string = remove_triple_newlines(&as_string);\n        let mut file = std::fs::File::create(toml_path)?;\n        file.write_all(new_string.as_bytes())?;\n    }\n\n    // 4. Remove any triple newlines from the readme.\n    let readme_path = path.join(\"README.md\");\n    let readme = std::fs::read_to_string(&readme_path)?;\n    let new_readme = remove_triple_newlines(&readme);\n    let mut file = std::fs::File::create(readme_path)?;\n    file.write_all(new_readme.as_bytes())?;\n\n    // 5. Run git init","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/cli/src/cli/create.rs#L180-L216","documentation":"As a post-creation step, dx formats the freshly generated Cargo.toml and Dioxus.toml by parsing them with toml_edit::DocumentMut and rewriting. If either file fails to parse as TOML, the command aborts with this error including the file path and the parser's message. Since both files were just generated, a parse failure almost always means a broken/custom template or concurrent modification.","triggerScenarios":"dx create with a custom template that emits malformed TOML, or an external tool (editor autoformat, file watcher, pre-commit hook) mutating Cargo.toml/Dioxus.toml between generation and the formatting step.","commonSituations":"Using a community template with invalid TOML; an old dx version shipping a broken default template; aggressive editor format-on-save racing the scaffold.","solutions":["Open the file named in the error and fix the TOML syntax at the position the parser reports","Re-run dx create without the custom template to confirm the default template is healthy","Update dx (check dx --version) if a stale CLI ships broken templates","If a specific custom template always fails, fix or report it upstream"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Sanity-parse the generated TOML right after dx create\npython3 -c 'import tomllib,sys; tomllib.load(open(sys.argv[1],\"rb\"))' path/to/Cargo.toml","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer stock templates unless a custom one is known-good","Keep dx updated so scaffold templates stay valid","Disable format-on-save for files under a freshly scaffolded directory until dx finishes"],"tags":["cli","create","toml","template"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}