DioxusLabs/dioxus · error · anyhow::Error
Failed to add dependency {} to Cargo.toml
Error message
Failed to add dependency {} to Cargo.toml What it means
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.
Source
Thrown at packages/cli/src/cli/component.rs:329
}
Ok(config.components.registry.clone())
}
/// Add any rust dependencies required for a component
async fn add_rust_dependencies(dependencies: &HashSet<CargoDependency>) -> Result<()> {
for dep in dependencies {
let status = Command::from(dep.add_command())
.status()
.await
.with_context(|| {
format!(
"Failed to run command to add dependency {} to Cargo.toml",
dep.name()
)
})?;
if !status.success() {
bail!("Failed to add dependency {} to Cargo.toml", dep.name());
}
}
Ok(())
}
}
/// Arguments for the default or custom remote registry
/// If both values are None, the default registry will be used
#[derive(Clone, Debug, Parser, Default, Serialize, Deserialize, JsonSchema)]
pub struct RemoteComponentRegistry {
/// The url of the component registry
#[arg(long)]
git: Option<String>,
/// The revision of the component registry
#[arg(long)]
rev: Option<String>,View on GitHub (pinned to 24f6a829df)
Solutions
- The dependency could not be added to Cargo.toml. Check the dependency name and version and that Cargo.toml is writable.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/cli/src/cli/component.rs:329 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/e4f5123722b4693d.
Report an issue: GitHub.