{"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":"validation","errorClass":"anyhow::Error","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/2f1cd75b0f3fb72e6870d719bbfeadedcf8ca884/crates/tauri-build/src/lib.rs#L56-L92","documentation":"tauri-build copies each sidecar (bundle.externalBin) into the bundle next to the main executable, stripping the target-triple suffix (e.g. -x86_64-unknown-linux-gnu) from the file name first. If the resulting name equals the Cargo package name, the copy would clobber the app's own binary, so the build aborts with this explicit collision error.","triggerScenarios":"bundle.externalBin contains an entry whose file name, after removing the '-<target_triple>' suffix, equals the crate's package name - e.g. package 'myapp' with external binary 'myapp-x86_64-unknown-linux-gnu' resolving to file_name 'myapp'.","commonSituations":"Trying to ship a helper binary named the same as the app; renaming the project so the crate name now collides with an existing sidecar; templates where the sidecar was casually named after the app.","solutions":["Rename the sidecar binary on disk (e.g. myapp -> myapp-helper) keeping the target-triple suffix, and update the externalBin entry in tauri.conf.json to match","Alternatively rename the Cargo package if the binary file name must stay as-is (usually the heavier change)","Rebuild; the collision check runs on every tauri build"],"exampleFix":"// before: binaries/myapp-x86_64-unknown-linux-gnu + package name 'myapp'\n\"externalBin\": [\"binaries/myapp-x86_64-unknown-linux-gnu\"]\n\n// after: renamed file binaries/myapp-helper-x86_64-unknown-linux-gnu\n\"externalBin\": [\"binaries/myapp-helper-x86_64-unknown-linux-gnu\"]","handlingStrategy":"validation","validationCode":"// prebuild check: sidecar name (minus target triple) must differ from package name\nconst { readFileSync } = require('fs')\nconst pkg = JSON.parse(readFileSync('src-tauri/Cargo.toml', 'utf8')) // or parse toml properly\nconst cfg = JSON.parse(readFileSync('src-tauri/tauri.conf.json', 'utf8'))\nconst name = /name\\s*=\\s*\"([^\"]+)\"/.exec(readFileSync('src-tauri/Cargo.toml', 'utf8'))[1]\nfor (const b of cfg.bundle?.externalBin ?? []) {\n  const base = b.split('/').pop().replace(/-[a-z0-9_-]+-(musl|gnu|msvc)$/, '')\n  if (base === name) throw new Error(`sidecar ${b} collides with package name ${name}`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name sidecars with a role suffix (-helper, -agent, -cli) from day one","After renaming a crate, check externalBin entries for collisions","Automate the name check in CI before tauri build"],"tags":["tauri-build","sidecar","bundle","naming"],"backgroundTag":null,"analyzedSha":"2f1cd75b0f3fb72e6870d719bbfeadedcf8ca884","analyzedAt":"2026-08-16T04:18:42.486Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}