tauri-apps/tauri · error

failed to convert zip_path to string

Error message

failed to convert zip_path to string

What it means

This panic fires in notarize_inner when zip_path.to_str() returns None. zip_path is built as tempdir/<bundle_stem>.zip; conversion to &str fails only if the temporary directory path contains non-UTF-8 bytes. The path is needed as a command-line argument for ditto.

Solutions

  1. Ensure TMPDIR points to a valid UTF-8 path before running the notarization
  2. Unset or correct a misconfigured TMPDIR env var
  3. Use a default temp location like /tmp if a custom one is problematic

Example fix

// before
export TMPDIR=$'\xff\xfe/tmp'
cargo tauri build
// after
unset TMPDIR   # or set TMPDIR=/tmp
cargo tauri build
Defensive patterns

Strategy: validation

Validate before calling

if let Some(tmp) = std::env::var_os("TMPDIR") {
    assert!(Path::new(&tmp).to_str().is_some(), "TMPDIR must be UTF-8");
}

Type guard

fn is_utf8_env(key: &str) -> bool {
    std::env::var_os(key).map(|v| v.to_str().is_some()).unwrap_or(true)
}

Prevention

When it happens

Trigger: Calling notarize/notarize_without_stapling on a system where TMPDIR resolves to a non-UTF-8 path, making the tempfile-created zip path unrepresentable as &str.

Common situations: Non-standard TMPDIR environment variables set to paths with non-UTF-8 bytes in CI containers or exotic setups.

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

Appendix: source

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

  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)?;

  let mut notarize_args = vec![
    "notarytool",

View on GitHub (pinned to 460ec35447)