{"record":{"id":"780ff678f1f214ba","repo":"DioxusLabs/dioxus","slug":"failed-to-execute-process","errorCode":null,"errorMessage":"failed to execute process","messagePattern":"failed to execute process","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/cli/create.rs","lineNumber":183,"sourceCode":"    metadata.and_then(|metadata| {\n        let cargo_toml_path = &metadata.workspace_root.join(\"Cargo.toml\");\n        let cargo_toml_str = std::fs::read_to_string(cargo_toml_path).ok()?;\n        let relative_path = path.strip_prefix(metadata.workspace_root).ok()?;\n\n        let mut cargo_toml: toml_edit::DocumentMut = cargo_toml_str.parse().ok()?;\n        cargo_toml\n            .get_mut(\"workspace\")?\n            .get_mut(\"members\")?\n            .as_array_mut()?\n            .push(relative_path.display().to_string());\n\n        std::fs::write(cargo_toml_path, cargo_toml.to_string()).ok()\n    });\n\n    // 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();","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/cli/src/cli/create.rs#L165-L201","documentation":"After dx new/create scaffolds a project it runs `cargo fmt` on it; the .expect(\"failed to execute process\") fires when the OS cannot spawn the cargo process at all. A cargo fmt that runs but reports errors is only logged, not fatal - only spawn failure panics.","triggerScenarios":"Running `dx new` without cargo on PATH, or with a cargo that is not executable (broken rustup shim, permission denied, `rustup default none`).","commonSituations":"dx installed standalone (brew/npm) on a machine without a Rust toolchain; PATH broken in the shell/IDE that launched dx; toolchain removed while dx remains installed.","solutions":["Install Rust via rustup and confirm `cargo --version` works in the same shell that runs dx","Fix PATH so the cargo shim resolves (source the environment, restart the terminal/IDE)","If the project was created anyway, run `cargo fmt` manually inside it - the scaffold is complete"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check cargo is spawnable before running dx new\nfn cargo_available() -> bool {\n    std::process::Command::new(\"cargo\")\n        .arg(\"--version\")\n        .stdout(std::process::Stdio::null())\n        .stderr(std::process::Stdio::null())\n        .status()\n        .map(|s| s.success())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the Rust toolchain with rustup before using dx new","Verify `cargo --version` in the exact shell/IDE that launches dx","If scaffolding completed, just run `cargo fmt` manually in the project"],"tags":["cli","dx-new","cargo","process-spawn","environment"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}