tauri-apps/tauri · error

No data in parent

Error message

No data in parent

What it means

fs_utils::copy_file computes the destination's parent directory with Path::parent().expect("No data in parent") before creating directories and copying. If the destination path has no parent component (a bare relative file name like 'out.txt'), the panic fires instead of a normal error. The library assumes callers pass destination paths that include a directory.

Solutions

  1. Ensure the destination path in the bundler config always includes a directory (e.g. 'bin/helper.exe', not 'helper.exe').
  2. Check resources/files mappings in tauri.conf.json for entries whose destination is a bare filename.
  3. If invoking copy_file directly, wrap the destination in a directory first (e.g. dest_dir.join(filename)).
  4. Debug with the printed paths: catch upstream by validating to.parent().is_some() before calling.

Example fix

// before
fs_utils::copy_file(&src, Path::new("out.txt"))?;
// after
fs_utils::copy_file(&src, &Path::new(".").join("out.txt"))?;
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check destination before calling copy_file
use std::path::Path;
fn dest_has_parent(dest: &Path) -> bool {
  dest.parent().map(|p| !p.as_os_str().is_empty()).unwrap_or(false)
}

Type guard

fn is_copyable_dest(to: &std::path::Path) -> bool {
  to.parent().is_some()
}

Prevention

When it happens

Trigger: copy_custom_files -> copy_file when a custom file's destination resolves to a single-component path with no directory (destination ends in a bare filename at filesystem root or a relative name with no prefix).

Common situations: Bundle resources/files configuration with a destination that is just a filename; tauri.conf.json 'files' map whose value lost its directory part; running the bundler from an odd working directory so relative paths collapse.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/tauri-bundler/src/utils/fs_utils.rs:92

fn symlink_file(src: &Path, dst: &Path) -> io::Result<()> {
  std::os::windows::fs::symlink_file(src, dst)
}

/// Copies a regular file from one path to another, creating any parent
/// directories of the destination path as necessary. Fails if the source path
/// is a directory or doesn't exist.
pub fn copy_file(from: &Path, to: &Path) -> crate::Result<()> {
  if !from.exists() {
    return Err(crate::Error::GenericError(format!(
      "{from:?} does not exist"
    )));
  }
  if !from.is_file() {
    return Err(crate::Error::GenericError(format!(
      "{from:?} is not a file"
    )));
  }
  let dest_dir = to.parent().expect("No data in parent");
  fs::create_dir_all(dest_dir)?;
  fs::copy(from, to)?;
  Ok(())
}

/// Recursively copies a directory file from one path to another, creating any
/// parent directories of the destination path as necessary.  Fails if the
/// source path is not a directory or doesn't exist, or if the destination path
/// already exists.
#[allow(dead_code)]
pub fn copy_dir(from: &Path, to: &Path) -> crate::Result<()> {
  if !from.exists() {
    return Err(crate::Error::GenericError(format!(
      "{from:?} does not exist"
    )));
  }
  if !from.is_dir() {
    return Err(crate::Error::GenericError(format!(

View on GitHub (pinned to 460ec35447)