tauri-apps/tauri · error

failed to extract external binary filename

Error message

failed to extract external binary filename

What it means

In the RPM bundler, each external binary (sidecar) is placed under /usr/bin by taking its `file_name()` and stripping the target-triple suffix. If a sidecar path has no final component, file_name() returns None and the expect panics. The bundler assumes `settings.external_binaries()` always yields paths that end in a real file name.

Solutions

  1. Correct the externalBin entry in tauri.conf.json to end with the actual binary file name (target triple is appended automatically, e.g. `binaries/myapp`).
  2. Ensure the sidecar file exists for the current target triple (`myapp-x86_64-unknown-linux-gnu`) next to the configured path.
  3. Normalize any dynamically generated paths (no trailing slashes, no `..`) before building.
  4. Test with `tauri build --bundles rpm` after fixing to confirm the path resolves.

Example fix

// before
"externalBin": ["binaries/myapp-"]
// after
"externalBin": ["binaries/myapp"]
Defensive patterns

Strategy: validation

Validate before calling

for bin in &config.bundle.external_bin {
  let p = std::path::Path::new(bin);
  assert!(p.file_name().is_some(), "externalBin path has no filename: {bin}");
  let with_triple = format!("{}-{}", bin, target_triple);
  assert!(std::path::Path::new(&with_triple).is_file(), "sidecar missing: {with_triple}");
}

Type guard

fn has_file_name(p: &std::path::Path) -> bool { p.file_name().is_some() }

Prevention

When it happens

Trigger: tauri build producing an RPM bundle with `bundle.externalBin` entries whose resolved path lacks a filename component — trailing separator, `..`, or an empty name after variable substitution.

Common situations: Config like `"externalBin": ["binaries/"]`; a script-generated sidecar path where the binary name variable was empty; renaming a sidecar without updating the config so a stale directory path lingers.

Related errors


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

Appendix: source

Thrown at crates/tauri-bundler/src/bundle/linux/rpm.rs:153

    .unwrap_or_default()
  {
    builder = builder.obsoletes(Dependency::any(dep));
  }

  // Add binaries
  for bin in settings.binaries() {
    let src = settings.binary_path(bin);
    let dest = Path::new("/usr/bin").join(bin.name());
    builder = builder.with_file(src, FileOptions::new(dest.to_string_lossy()))?;
  }

  // Add external binaries
  for src in settings.external_binaries() {
    let src = src?;
    let dest = Path::new("/usr/bin").join(
      src
        .file_name()
        .expect("failed to extract external binary filename")
        .to_string_lossy()
        .replace(&format!("-{}", settings.target()), ""),
    );
    builder = builder.with_file(&src, FileOptions::new(dest.to_string_lossy()))?;
  }

  // Add scripts
  if let Some(script_path) = &settings.rpm().pre_install_script {
    let script = fs::read_to_string(script_path)?;
    builder = builder.pre_install_script(script);
  }

  if let Some(script_path) = &settings.rpm().post_install_script {
    let script = fs::read_to_string(script_path)?;
    builder = builder.post_install_script(script);
  }

  if let Some(script_path) = &settings.rpm().pre_remove_script {

View on GitHub (pinned to 460ec35447)