{"record":{"id":"b9c12c34682ef349","repo":"tauri-apps/tauri","slug":"no-data-in-parent-fs-utils","errorCode":null,"errorMessage":"No data in parent","messagePattern":"No data in parent","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/utils/fs_utils.rs","lineNumber":92,"sourceCode":"fn symlink_file(src: &Path, dst: &Path) -> io::Result<()> {\n  std::os::windows::fs::symlink_file(src, dst)\n}\n\n/// Copies a regular file from one path to another, creating any parent\n/// directories of the destination path as necessary. Fails if the source path\n/// is a directory or doesn't exist.\npub fn copy_file(from: &Path, to: &Path) -> crate::Result<()> {\n  if !from.exists() {\n    return Err(crate::Error::GenericError(format!(\n      \"{from:?} does not exist\"\n    )));\n  }\n  if !from.is_file() {\n    return Err(crate::Error::GenericError(format!(\n      \"{from:?} is not a file\"\n    )));\n  }\n  let dest_dir = to.parent().expect(\"No data in parent\");\n  fs::create_dir_all(dest_dir)?;\n  fs::copy(from, to)?;\n  Ok(())\n}\n\n/// Recursively copies a directory file from one path to another, creating any\n/// parent directories of the destination path as necessary.  Fails if the\n/// source path is not a directory or doesn't exist, or if the destination path\n/// already exists.\n#[allow(dead_code)]\npub fn copy_dir(from: &Path, to: &Path) -> crate::Result<()> {\n  if !from.exists() {\n    return Err(crate::Error::GenericError(format!(\n      \"{from:?} does not exist\"\n    )));\n  }\n  if !from.is_dir() {\n    return Err(crate::Error::GenericError(format!(","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-bundler/src/utils/fs_utils.rs#L74-L110","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Ensure the destination path in the bundler config always includes a directory (e.g. 'bin/helper.exe', not 'helper.exe').","Check resources/files mappings in tauri.conf.json for entries whose destination is a bare filename.","If invoking copy_file directly, wrap the destination in a directory first (e.g. dest_dir.join(filename)).","Debug with the printed paths: catch upstream by validating to.parent().is_some() before calling."],"exampleFix":"// before\nfs_utils::copy_file(&src, Path::new(\"out.txt\"))?;\n// after\nfs_utils::copy_file(&src, &Path::new(\".\").join(\"out.txt\"))?;","handlingStrategy":"validation","validationCode":"// Pre-check destination before calling copy_file\nuse std::path::Path;\nfn dest_has_parent(dest: &Path) -> bool {\n  dest.parent().map(|p| !p.as_os_str().is_empty()).unwrap_or(false)\n}","typeGuard":"fn is_copyable_dest(to: &std::path::Path) -> bool {\n  to.parent().is_some()\n}","tryCatchPattern":null,"preventionTips":["Always join destination filenames onto an explicit base directory.","Audit file/resource mappings in tauri.conf.json for bare-filename destinations.","Standardize the working directory used for bundling."],"tags":["filesystem","path","copy","panic"],"backgroundTag":"invalid-argument-value","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}