tauri-apps/tauri · error

failed to convert bundle_path to string

Error message

failed to convert bundle_path to string

What it means

This panic fires in notarize_inner when app_bundle_path.to_str() returns None, i.e. the bundle path contains invalid UTF-8 (Rust OsStr/Path are not guaranteed UTF-8). The path is interpolated into a ditto command-line argument vector, which requires a &str, so the library panics when conversion fails.

Solutions

  1. Rename the app bundle and its parent directories to use only valid UTF-8 (ideally ASCII) names
  2. Validate the path with .to_str().is_some() before calling notarize
  3. If the path comes from env::current_dir or user input, sanitize or reject non-UTF-8 paths early

Example fix

// before
let bundle = PathBuf::from(std::env::var_os("BUNDLE").unwrap());
notarize(&bundle, &auth, true).unwrap();
// after
let bundle = PathBuf::from(std::env::var_os("BUNDLE").unwrap());
assert!(bundle.to_str().is_some(), "bundle path must be valid UTF-8");
notarize(&bundle, &auth, true).unwrap();
Defensive patterns

Strategy: validation

Validate before calling

fn assert_utf8(p: &Path) {
    assert!(p.to_str().is_some(), "path not valid UTF-8: {:?}", p);
}
assert_utf8(&bundle_path);

Type guard

fn is_utf8_path(p: &Path) -> bool { p.to_str().is_some() }

Prevention

When it happens

Trigger: Calling notarize or notarize_without_stapling with an app bundle path containing non-UTF-8 bytes (e.g. exotic encodings from a mounted volume or unusual filenames).

Common situations: macOS paths built from user-supplied folder names with non-UTF-8 characters, or paths constructed from raw bytes on unusual filesystems.

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/a2320cdfbeaf2eb4. Report an issue: GitHub.

Appendix: source

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

  auth: &AppleNotarizationCredentials,
  wait: bool,
) -> Result<()> {
  let bundle_stem = app_bundle_path
    .file_stem()
    .expect("failed to get bundle filename");

  let tmp_dir = tempfile::tempdir().map_err(Error::TempDir)?;
  let zip_path = tmp_dir
    .path()
    .join(format!("{}.zip", bundle_stem.to_string_lossy()));
  let zip_args = vec![
    "-c",
    "-k",
    "--keepParent",
    "--sequesterRsrc",
    app_bundle_path
      .to_str()
      .expect("failed to convert bundle_path to string"),
    zip_path
      .to_str()
      .expect("failed to convert zip_path to string"),
  ];

  // use ditto to create a PKZip almost identical to Finder
  // this remove almost 99% of false alarm in notarization
  assert_command(
    Command::new("ditto").args(zip_args).piped(),
    "failed to zip app with ditto",
  )
  .map_err(|error| Error::CommandFailed {
    command: "ditto".to_string(),
    error,
  })?;

  // sign the zip file
  keychain.sign(&zip_path, None, false)?;

View on GitHub (pinned to 460ec35447)