{"record":{"id":"59acdb88e445cb0d","repo":"tauri-apps/tauri","slug":"cannot-define-a-sidecar-with-the-same-name-as-the","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-build/src/lib.rs","lineNumber":74,"sourceCode":"}\n\nfn copy_binaries(\n  binaries: ResourcePaths,\n  target_triple: &str,\n  path: &Path,\n  package_name: Option<&str>,\n) -> Result<()> {\n  for src in binaries {\n    let src = src?;\n    println!(\"cargo:rerun-if-changed={}\", src.display());\n    let file_name = src\n      .file_name()\n      .expect(\"failed to extract external binary filename\")\n      .to_string_lossy()\n      .replace(&format!(\"-{target_triple}\"), \"\");\n\n    if package_name == Some(&file_name) {\n      return Err(anyhow::anyhow!(\n        \"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.\",\n        file_name\n      ));\n    }\n\n    let dest = path.join(file_name);\n    if dest.exists() {\n      fs::remove_file(&dest).unwrap();\n    }\n    copy_file(&src, &dest)?;\n  }\n  Ok(())\n}\n\n/// Copies resources to a path.\nfn copy_resources(resources: ResourcePaths<'_>, path: &Path) -> Result<()> {\n  let path = path.canonicalize()?;\n  let mut resources = resources.iter();","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-build/src/lib.rs#L56-L92","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename the sidecar binary on disk and update the `externalBin` entry in tauri.conf.json","Or rename the Cargo package so the names differ","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"],"exampleFix":"// before\n\"externalBin\": [\"binaries/myapp\"]  // package is also named myapp\n// after\n\"externalBin\": [\"binaries/myapp-helper\"]  // rename file to myapp-helper-<triple>","handlingStrategy":"validation","validationCode":"const pkg = JSON.parse(fs.readFileSync('src-tauri/Cargo.toml','utf8')); // or parse name via toml\nconst name = 'myapp'; // package name\nfor (const bin of cfg.bundle?.externalBin ?? []) {\n  const stripped = basename(bin).replace(new RegExp(`-${process.env.TARGET_TRIPLE}$`), '');\n  if (stripped === name) throw new Error(`Sidecar name equals package name: ${stripped}`);\n}","typeGuard":"const collides = (bin: string, pkg: string) => bin.replace(new RegExp(`-${targetTriple}$`), '').endsWith('/' + pkg) || bin === pkg;","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (String(e).includes('same name as the Cargo package name')) {\n    throw new Error('Rename the sidecar binary and its externalBin entry');\n  }\n  throw e;\n}","preventionTips":["Adopt a naming convention that keeps sidecars distinct from the crate name (e.g. prefix `bin/` and suffix `-bin`)","Check after any crate rename that externalBin entries still differ","Strip the target-triple suffix mentally when reviewing sidecar names"],"tags":["sidecar","build","naming-conflict","tauri-build"],"backgroundTag":"conflicting-config-options","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}