tauri-apps/tauri · error · io::Error

Non-UTF-8 path

Error message

Non-UTF-8 path: {rel_path:?}

What it means

While generating the md5sums control file for a .deb package, every installed file's path relative to the data dir must be written as UTF-8 text. If a filename is not valid UTF-8, generate_md5sums creates this io::Error instead of producing a corrupt checksums file.

Solutions

  1. Rename the offending file(s) so their names are valid UTF-8 before bundling
  2. Fix the source of the resource files (extraction tool or archive) to use UTF-8 names
  3. Identify the culprit via the printed {rel_path:?} debug path in the error

Example fix

// before
$ ls data/usr/share/app  # file named config?lat?n (invalid bytes)
mv 'config?lat?n' config-latin.txt
// after
$ cargo tauri build --bundles deb  # proceeds
Defensive patterns

Strategy: validation

Validate before calling

// before bundling a deb, verify all payload filenames are UTF-8
const checkUtf8Names = (dir) => {
  for (const f of fs.readdirSync(dir, { recursive: true })) {
    const s = Buffer.from(f).toString('utf8');
    if (Buffer.from(s, 'utf8').toString('utf8') !== f || f.includes('\uFFFD')) throw new Error(`Non-UTF-8 filename: ${f}`);
  }
};

Try / catch

try {
  await bundleDeb();
} catch (e) {
  if (String(e).includes('Non-UTF-8 path')) console.error('Rename the printed file to a UTF-8 name and rebuild');
  throw e;
}

Prevention

When it happens

Trigger: Bundling a Debian package whose data directory contains a file or directory with non-UTF-8 encoded name (generate_md5sums iterates all files under data_dir).

Common situations: Packaging resources with filenames created on systems using legacy encodings (e.g. Latin-1), archives extracted with non-UTF-8 filename encoding, or files with invalid bytes from third-party tooling.

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

Appendix: source

Thrown at crates/tauri-bundler/src/bundle/linux/debian.rs:320

fn generate_md5sums(control_dir: &Path, data_dir: &Path) -> crate::Result<()> {
  let md5sums_path = control_dir.join("md5sums");
  let mut md5sums_file = fs_utils::create_file(&md5sums_path)?;
  for entry in WalkDir::new(data_dir) {
    let entry = entry?;
    let path = entry.path();
    if path.is_dir() {
      continue;
    }
    let mut file = File::open(path)?;
    let mut hash = md5::Context::new();
    io::copy(&mut file, &mut hash)?;
    for byte in hash.finalize().iter() {
      write!(md5sums_file, "{byte:02x}")?;
    }
    let rel_path = path.strip_prefix(data_dir)?;
    let path_str = rel_path.to_str().ok_or_else(|| {
      let msg = format!("Non-UTF-8 path: {rel_path:?}");
      io::Error::new(io::ErrorKind::InvalidData, msg)
    })?;
    writeln!(md5sums_file, "  {path_str}")?;
  }
  Ok(())
}

/// Copy the bundle's resource files into an appropriate directory under the
/// `data_dir`.
fn copy_resource_files(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
  let resource_dir = data_dir.join("usr/lib").join(settings.product_name());
  settings.copy_resources(&resource_dir)
}

/// Create an empty file at the given path, creating any parent directories as
/// needed, then write `data` into the file.
fn create_file_with_data<P: AsRef<Path>>(path: P, data: &str) -> crate::Result<()> {
  let mut file = fs_utils::create_file(path.as_ref())?;
  file.write_all(data.as_bytes())?;

View on GitHub (pinned to 460ec35447)