{"record":{"id":"e4f5123722b4693d","repo":"DioxusLabs/dioxus","slug":"failed-to-add-dependency-to-cargo-toml","errorCode":null,"errorMessage":"Failed to add dependency {} to Cargo.toml","messagePattern":"Failed to add dependency (.+?) to Cargo\\.toml","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/cli/component.rs","lineNumber":329,"sourceCode":"        }\n\n        Ok(config.components.registry.clone())\n    }\n\n    /// Add any rust dependencies required for a component\n    async fn add_rust_dependencies(dependencies: &HashSet<CargoDependency>) -> Result<()> {\n        for dep in dependencies {\n            let status = Command::from(dep.add_command())\n                .status()\n                .await\n                .with_context(|| {\n                    format!(\n                        \"Failed to run command to add dependency {} to Cargo.toml\",\n                        dep.name()\n                    )\n                })?;\n            if !status.success() {\n                bail!(\"Failed to add dependency {} to Cargo.toml\", dep.name());\n            }\n        }\n\n        Ok(())\n    }\n}\n\n/// Arguments for the default or custom remote registry\n/// If both values are None, the default registry will be used\n#[derive(Clone, Debug, Parser, Default, Serialize, Deserialize, JsonSchema)]\npub struct RemoteComponentRegistry {\n    /// The url of the component registry\n    #[arg(long)]\n    git: Option<String>,\n\n    /// The revision of the component registry\n    #[arg(long)]\n    rev: Option<String>,","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/cli/src/cli/component.rs#L311-L347","documentation":"Raised in add_rust_dependencies when the cargo command generated to add a component's dependency (e.g. `cargo add`) either fails to spawn or completes with a failure indication for that dependency. This is an external tool failure around the dependency named in the message — the crate could not be added to Cargo.toml, typically due to registry/network issues or an unavailable crate version.","triggerScenarios":"Thrown at packages/cli/src/cli/component.rs:329 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The dependency could not be added to Cargo.toml. Check the dependency name and version and that Cargo.toml is writable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}