tauri-apps/tauri · error

Cannot define a sidecar with the same name as the Cargo…

Error message

Cannot define a sidecar with the same name as the Cargo package name `{}`. Please change the sidecar name in the filesystem and the Tauri configuration.

What it means

tauri-build refuses a sidecar/external binary whose name equals the Cargo package name, because the copied binary into target/(debug|release) would collide with (or be overwritten by) the crate's own built executable. The error names the offending file.

Solutions

  1. Rename the sidecar binary on disk and update the `externalBin` entry in tauri.conf.json
  2. Or rename the Cargo package so the names differ
  3. Ensure the sidecar file carries the target-triple suffix (e.g. mytool-x86_64-unknown-linux-gnu) so the stripped name is correct and distinct

Example fix

// before
"externalBin": ["binaries/myapp"]  // package is also named myapp
// after
"externalBin": ["binaries/myapp-helper"]  // rename file to myapp-helper-<triple>
Defensive patterns

Strategy: validation

Validate before calling

const pkg = JSON.parse(fs.readFileSync('src-tauri/Cargo.toml','utf8')); // or parse name via toml
const name = 'myapp'; // package name
for (const bin of cfg.bundle?.externalBin ?? []) {
  const stripped = basename(bin).replace(new RegExp(`-${process.env.TARGET_TRIPLE}$`), '');
  if (stripped === name) throw new Error(`Sidecar name equals package name: ${stripped}`);
}

Type guard

const collides = (bin: string, pkg: string) => bin.replace(new RegExp(`-${targetTriple}$`), '').endsWith('/' + pkg) || bin === pkg;

Try / catch

try {
  await build();
} catch (e) {
  if (String(e).includes('same name as the Cargo package name')) {
    throw new Error('Rename the sidecar binary and its externalBin entry');
  }
  throw e;
}

Prevention

When it happens

Trigger: In tauri.conf.json `bundle.externalBin`, an entry whose filename (after stripping the -<target-triple> suffix) matches the Cargo package name in Cargo.toml during try_build -> copy_binaries.

Common situations: Renaming a crate so it now matches an existing sidecar, adding a sidecar that wraps the same tool under the app's own name, or forgetting the target-triple suffix convention so the stripped name coincidentally equals the package name.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/59acdb88e445cb0d. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri-build/src/lib.rs:74

}

fn copy_binaries(
  binaries: ResourcePaths,
  target_triple: &str,
  path: &Path,
  package_name: Option<&str>,
) -> Result<()> {
  for src in binaries {
    let src = src?;
    println!("cargo:rerun-if-changed={}", src.display());
    let file_name = src
      .file_name()
      .expect("failed to extract external binary filename")
      .to_string_lossy()
      .replace(&format!("-{target_triple}"), "");

    if package_name == Some(&file_name) {
      return Err(anyhow::anyhow!(
        "Cannot define a sidecar with the same name as the Cargo package name `{}`. Please change the sidecar name in the filesystem and the Tauri configuration.",
        file_name
      ));
    }

    let dest = path.join(file_name);
    if dest.exists() {
      fs::remove_file(&dest).unwrap();
    }
    copy_file(&src, &dest)?;
  }
  Ok(())
}

/// Copies resources to a path.
fn copy_resources(resources: ResourcePaths<'_>, path: &Path) -> Result<()> {
  let path = path.canonicalize()?;
  let mut resources = resources.iter();

View on GitHub (pinned to 460ec35447)