tauri-apps/tauri · error
Failed to install Cargo dependency
Error message
Failed to install Cargo dependency
What it means
The helper runs `cargo add <name> ...` (inheriting stdio) and checks the exit status. Cargo's own diagnostic has already been printed to the terminal; this error is the CLI's summary that the dependency could not be added to the manifest.
Source
Thrown at crates/tauri-cli/src/helpers/cargo.rs:62
_ => crate::error::bail!("Only one of --tag, --rev and --branch can be specified"),
};
}
if let Some(target) = options.target {
cargo.args(["--target", target]);
}
if let Some(cwd) = options.cwd {
cargo.current_dir(cwd);
}
log::info!("Installing Cargo dependency \"{}\"...", options.name);
let status = cargo.status().map_err(|error| Error::CommandFailed {
command: "cargo add".to_string(),
error,
})?;
if !status.success() {
crate::error::bail!("Failed to install Cargo dependency");
}
Ok(())
}
#[derive(Debug, Default, Clone, Copy)]
pub struct CargoUninstallOptions<'a> {
pub name: &'a str,
pub cwd: Option<&'a std::path::Path>,
pub target: Option<&'a str>,
}
pub fn uninstall_one(options: CargoUninstallOptions) -> crate::Result<()> {
let mut cargo = Command::new("cargo");
cargo.arg("remove");
cargo.arg(options.name);
View on GitHub (pinned to 52e4b6e71d)
Solutions
- Scroll up and read the cargo error printed just above this message — it names the real cause (403 from registry, version not found, etc.)
- Reproduce manually: `cargo add tauri-plugin-<name>` inside `src-tauri` and fix what it complains about
- For network issues, check proxy/offline settings (`cargo --config net.offline=false`, `~/.cargo/config.toml`) and registry reachability
Defensive patterns
Strategy: validation
Validate before calling
# smoke-test cargo registry access and manifest writability before tauri add
cd src-tauri
cargo search tauri-plugin-dialog --limit 1 >/dev/null # fails fast offline / bad proxy
[ -w Cargo.toml ] || { echo 'Cargo.toml not writable' >&2; exit 1; } Prevention
- Pre-verify network/proxy access to crates.io in restricted environments
- Run `cargo add tauri-plugin-<name>` manually once when onboarding a plugin to see real errors
- Keep cargo and Cargo.toml healthy (no conflict markers) before plugin installs
When it happens
Trigger: `tauri add <plugin>` where the underlying `cargo add tauri-plugin-<name>` fails: crate version not found, network/registry unreachable, incompatible Rust edition/MSRV, or a Cargo.toml that is locked/read-only.
Common situations: Corporate proxies or offline environments blocking crates.io; requesting a plugin version not yet published; cargo not installed or an ancient cargo without `cargo add`; Cargo.toml merge conflicts left in place.
Related errors
- Failed to remove Cargo dependency
- No external IP detected.
- Couldn't bind to {port} on {ip}
- Only one of --tag, --rev and --branch can be specified
- Failed to install NPM {dependencies_str}
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/c4ce51e69180efb2.
Report an issue: GitHub.