tauri-apps/tauri · error

failed to convert bundle filename to string

Error message

failed to convert bundle filename to string

What it means

staple_app converts the bundle filename to &str for the xcrun stapler invocation; the panic means the final path component contains invalid UTF-8. The filename must be passed as a command-line argument, which requires UTF-8.

Solutions

  1. Rename the .app bundle to a UTF-8 (preferably ASCII) name before notarizing
  2. Check any rename/copy step in the build script for byte-level operations
  3. Validate path.to_str() early in the pipeline

Example fix

// before
mv "My App\xff.app" dist/My\xffApp.app
// after
mv "My App.app" dist/MyApp.app
Defensive patterns

Strategy: validation

Validate before calling

assert!(
    bundle_path.file_name().and_then(|n| n.to_str()).is_some(),
    "bundle filename must be valid UTF-8"
);

Type guard

fn utf8_file_name(p: &Path) -> Option<&str> { p.file_name()?.to_str() }

Prevention

When it happens

Trigger: notarize finishing successfully and calling staple_app with a bundle whose file name has non-UTF-8 bytes.

Common situations: App bundles named with characters outside UTF-8 from unusual filesystems or scripted renames.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at crates/tauri-macos-sign/src/lib.rs:258

        String::from_utf8_lossy(&output.stdout)
      )))
    } else {
      Err(Error::Notarize(log_message))
    }
  } else {
    Err(Error::ParseNotarytoolOutput {
      output: output_str.into_owned(),
    })
  }
}

fn staple_app(mut app_bundle_path: PathBuf) -> Result<()> {
  let app_bundle_path_clone = app_bundle_path.clone();
  let filename = app_bundle_path_clone
    .file_name()
    .expect("failed to get bundle filename")
    .to_str()
    .expect("failed to convert bundle filename to string");

  app_bundle_path.pop();

  Command::new("xcrun")
    .args(vec!["stapler", "staple", "-v", filename])
    .current_dir(app_bundle_path)
    .output()
    .map_err(|error| Error::CommandFailed {
      command: "xcrun stapler staple".to_string(),
      error,
    })?;

  Ok(())
}

pub trait NotarytoolCmdExt {
  fn notarytool_args(
    &mut self,

View on GitHub (pinned to 460ec35447)