{"record":{"id":"dfbea57a321cc247","repo":"tauri-apps/tauri","slug":"failed-to-open-icon","errorCode":null,"errorMessage":"failed to open icon {}: {}","messagePattern":"failed to open icon (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-codegen/src/image.rs","lineNumber":102,"sourceCode":"    }\n\n    let mut rgba = Vec::with_capacity(reader.output_buffer_size().unwrap());\n    while let Ok(Some(row)) = reader.next_row() {\n      rgba.extend(row.data());\n    }\n\n    Cached::try_from(rgba).map(|cache| Self {\n      cache,\n      root: root.clone(),\n      format: IconFormat::Image {\n        width: reader.info().width,\n        height: reader.info().height,\n      },\n    })\n  }\n\n  fn open(path: &Path) -> Vec<u8> {\n    std::fs::read(path).unwrap_or_else(|e| panic!(\"failed to open icon {}: {}\", path.display(), e))\n  }\n}\n\nimpl ToTokens for CachedIcon {\n  fn to_tokens(&self, tokens: &mut TokenStream) {\n    let root = &self.root;\n    let cache = &self.cache;\n    let raw = quote!(::std::include_bytes!(#cache));\n    tokens.append_all(match self.format {\n      IconFormat::Raw => raw,\n      IconFormat::Image { width, height } => {\n        quote!(#root::image::Image::new(#raw, #width, #height))\n      }\n    })\n  }\n}\n","sourceCodeStart":84,"sourceCodeEnd":119,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-codegen/src/image.rs#L84-L119","documentation":"CachedIcon::open reads the icon file from disk with std::fs::read during macro expansion. Any IO failure (missing file, permission denied, path is a directory) panics with `failed to open icon {path}: {io error}`, aborting the build before any decoding happens.","triggerScenarios":"The icon path passed to icon!/embedded assets does not exist or is unreadable: typo in path, path relative to the wrong crate root, file deleted, or a directory passed instead of a file.","commonSituations":"Referencing icons/32x32.png that only exists in another crate; case mismatch on Linux/CI; icons excluded by .gitignore so CI checkouts lack them; running the build from a workspace where the relative path differs.","solutions":["Fix the icon path so it resolves relative to the invoking crate (use CARGO_MANIFEST_DIR-based paths if needed)","Confirm the file exists with correct casing (`ls src/icons/`)","Commit the icon to the repo and un-ignore it","Replace the directory path with the path to the actual file"],"exampleFix":"// before\nlet icon = tauri::icon!(\"../branding/logo.ico\");\n// after\nlet icon = tauri::icon!(concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/icons/logo.ico\"));","handlingStrategy":"validation","validationCode":"import os, sys\np = os.path.join(os.environ.get('CARGO_MANIFEST_DIR',''), 'icons/logo.ico')\nif not os.path.isfile(p):\n    sys.exit(f'icon missing: {p}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Anchor icon paths with CARGO_MANIFEST_DIR in macros","Ensure icons are committed and not gitignored","Check file casing for Linux/CI builds","Use file paths, never directory paths, for icons"],"tags":["icon","file-io","path","codegen"],"backgroundTag":"file-not-found","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"}