{"record":{"id":"604a8149a3566bdf","repo":"tauri-apps/tauri","slug":"path-has-no-file-name","errorCode":null,"errorMessage":"Path has no file_name","messagePattern":"Path has no file_name","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/updater_bundle.rs","lineNumber":249,"sourceCode":"fn create_tar(src_dir: &Path, dest_path: &Path) -> crate::Result<PathBuf> {\n  use flate2::{Compression, write::GzEncoder};\n\n  let dest_file = fs_utils::create_file(dest_path)?;\n  let gzip_encoder = GzEncoder::new(dest_file, Compression::default());\n\n  let gzip_encoder = create_tar_from_src(src_dir, gzip_encoder)?;\n\n  let mut dest_file = gzip_encoder.finish()?;\n  dest_file.flush()?;\n  Ok(dest_path.to_owned())\n}\n\n#[cfg(target_os = \"macos\")]\nfn create_tar_from_src<P: AsRef<Path>, W: Write>(src_dir: P, dest_file: W) -> crate::Result<W> {\n  let src_dir = src_dir.as_ref();\n  let mut builder = tar::Builder::new(dest_file);\n  builder.follow_symlinks(false);\n  builder.append_dir_all(src_dir.file_name().expect(\"Path has no file_name\"), src_dir)?;\n  builder.into_inner().map_err(Into::into)\n}\n\n#[cfg(target_os = \"linux\")]\nfn create_tar_from_src<P: AsRef<Path>, W: Write>(src_dir: P, dest_file: W) -> crate::Result<W> {\n  let src_dir = src_dir.as_ref();\n  let mut tar_builder = tar::Builder::new(dest_file);\n\n  // validate source type\n  let file_type = fs::metadata(src_dir).expect(\"Can't read source directory\");\n  // if it's a file don't need to walkdir\n  if file_type.is_file() {\n    let mut src_file = fs::File::open(src_dir)?;\n    let file_name = src_dir\n      .file_name()\n      .expect(\"Can't extract file name from path\");\n\n    tar_builder.append_file(file_name, &mut src_file)?;","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-bundler/src/bundle/updater_bundle.rs#L231-L267","documentation":"Panic from `.expect(\"Path has no file_name\")` in the macOS `create_tar_from_src`. The function appends the source directory itself into the tar via `append_dir_all(src_dir.file_name()..., src_dir)`, so it needs the directory's final path component as the archive entry name. `file_name()` returns `None` when the path is a root, ends in `..`, or is empty, and the bundler panics rather than emitting a partial archive.","triggerScenarios":"Calling `create_tar`/`create_tar_from_src` on macOS with a `src_dir` that is `/`, a drive/volume root, ends in `..`, or otherwise has no last component. Reached during macOS updater bundle generation.","commonSituations":"Passing a volume root (e.g. `/Volumes/`) or a path with `..` as the app bundle directory, misconfigured `bundle` output paths in tauri.conf.json, or paths built by repeated `pop()`/`join(\"..\")` calls that reduced the path past its last component.","solutions":["Canonicalize `src_dir` before calling so `..` components are resolved (`std::fs::canonicalize`)","Pass the actual `.app`/directory path (with a real final component) as the source, not a parent or root path","Avoid building the directory path with `join(\"..\")`; keep a direct path to the bundle directory","Pre-validate in calling code: `assert!(src_dir.file_name().is_some())` or return an explicit error"],"exampleFix":"// before\nlet dir = cfg_out.join(\"..\").join(\"myapp.app\");\ncreate_tar(dir, dest)?; // panics if join(\"..\") is last component\n// after\nlet dir = cfg_out.join(\"..\").join(\"myapp.app\").canonicalize()?;\ncreate_tar(dir, dest)?;","handlingStrategy":"validation","validationCode":"fn ensure_dir_with_name(p: &std::path::Path) -> Result<(), String> {\n    if !p.is_dir() {\n        return Err(format!(\"not a directory: {}\", p.display()));\n    }\n    if p.file_name().is_none() {\n        return Err(format!(\"directory path has no final component: {}\", p.display()));\n    }\n    Ok(())\n}\n// call before create_tar on macOS","typeGuard":"fn has_file_name(p: &std::path::Path) -> bool {\n    p.file_name().is_some()\n}","tryCatchPattern":null,"preventionTips":["Pass the direct path to the .app bundle, not a parent, root, or ..-terminated path","Canonicalize the directory before bundling","Avoid join(\"..\") when constructing bundle paths","Keep the bundler path in tauri.conf.json pointing at a real, existing directory"],"tags":["path","panic","updater","macos","tar"],"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"}