{"record":{"id":"dd65c1e5a690fb09","repo":"tauri-apps/tauri","slug":"could-not-get-icon-filename","errorCode":null,"errorMessage":"Could not get icon filename","messagePattern":"Could not get icon filename","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/macos/icon.rs","lineNumber":32,"sourceCode":"  process::Command,\n};\n\nuse image::GenericImageView;\n\n// Given a list of icon files, try to produce an ICNS file in the out_dir\n// and return the path to it.  Returns `Ok(None)` if no usable icons\n// were provided.\npub fn create_icns_file(out_dir: &Path, settings: &Settings) -> crate::Result<Option<PathBuf>> {\n  if settings.icon_files().count() == 0 {\n    return Ok(None);\n  }\n\n  // If one of the icon files is already an ICNS file, just use that.\n  for icon_path in settings.icon_files() {\n    let icon_path = icon_path?;\n    if icon_path.extension() == Some(OsStr::new(\"icns\")) {\n      let mut dest_path = out_dir.to_path_buf();\n      dest_path.push(icon_path.file_name().expect(\"Could not get icon filename\"));\n      fs_utils::copy_file(&icon_path, &dest_path)?;\n      return Ok(Some(dest_path));\n    }\n  }\n\n  // Otherwise, read available images and pack them into a new ICNS file.\n  let mut family = icns::IconFamily::new();\n\n  fn add_icon_to_family(\n    icon: image::DynamicImage,\n    density: u32,\n    family: &mut icns::IconFamily,\n  ) -> io::Result<()> {\n    // Try to add this image to the icon family.  Ignore images whose sizes\n    // don't map to any ICNS icon type; print warnings and skip images that\n    // fail to encode.\n    match icns::IconType::from_pixel_size_and_density(icon.width(), icon.height(), density) {\n      Some(icon_type) => {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-bundler/src/bundle/macos/icon.rs#L14-L50","documentation":"When creating the .icns for a macOS bundle, if an icon file already has an .icns extension the bundler copies it into the output under its own file name. file_name() returns None for paths that are a filesystem root or end with '..' or '.', so the expect fires only for a degenerate icon path.","triggerScenarios":"A bundle.icon entry in tauri.conf.json that resolves to a path with no final file-name component (e.g. '..', '.', or a root) while being treated as an .icns source during tauri build on macOS.","commonSituations":"Script- or template-generated tauri.conf.json where a variable interpolation is empty and collapses an icon path to a directory-like value; hand-edited typos in the icon list.","solutions":["Fix the offending bundle.icon entry to point at a real file, e.g. icons/AppIcon.icns","Audit the icon list: every entry must end in an actual file name with an image/icns extension","Prefer regenerating the icon list with tauri icon instead of hand-maintaining it"],"exampleFix":"// tauri.conf.json — before\n\"icon\": [\"icons/\", \"..\"]\n\n// after\n\"icon\": [\"icons/32x32.png\", \"icons/128x128.png\", \"icons/icon.icns\"]","handlingStrategy":"validation","validationCode":"// validate bundle.icon entries before building\nconst last = (p) => p.split('/').pop() ?? '';\nconst bad = config.bundle.icon.filter((p) => ['', '.', '..'].includes(last(p)));\nif (bad.length) throw new Error(`icon paths without a file name: ${bad.join(', ')}`);","typeGuard":"const hasIconFileName = (p) => { const seg = p.split('/').pop() ?? ''; return seg.length > 0 && seg !== '.' && seg !== '..'; };","tryCatchPattern":null,"preventionTips":["Lint bundle.icon so every entry ends in a real file name with an image/icns extension","Generate icon lists with tauri icon instead of hand-writing them","Fail builds on empty variable interpolation in generated tauri.conf.json"],"tags":["macos","icns","icons","path","tauri-bundler"],"backgroundTag":"invalid-path","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}