tauri-apps/tauri · error
failed to decode icon {}: {}
Error message
failed to decode icon {}: {} What it means
Compile-time panic in tauri-codegen's new_ico. The ICO container parsed successfully (IconDir::read) but decoding its first entry via entry.decode() failed, i.e. the embedded bitmap/PNG payload inside the ICO is invalid or unsupported, so RGBA data cannot be extracted for embedding.
Source
Thrown at crates/tauri-codegen/src/image.rs:60
let buf = Self::open(icon);
Cached::try_from(buf).map(|cache| Self {
cache,
root: root.clone(),
format: IconFormat::Raw,
})
}
/// Cache an ICO icon as RGBA data, see [`ImageFormat::Image`].
pub fn new_ico(root: &TokenStream, icon: &Path) -> EmbeddedAssetsResult<Self> {
let buf = Self::open(icon);
let icon_dir = ico::IconDir::read(Cursor::new(&buf))
.unwrap_or_else(|e| panic!("failed to parse icon {}: {}", icon.display(), e));
let entry = &icon_dir.entries()[0];
let rgba = entry
.decode()
.unwrap_or_else(|e| panic!("failed to decode icon {}: {}", icon.display(), e))
.rgba_data()
.to_vec();
Cached::try_from(rgba).map(|cache| Self {
cache,
root: root.clone(),
format: IconFormat::Image {
width: entry.width(),
height: entry.height(),
},
})
}
/// Cache a PNG icon as RGBA data, see [`ImageFormat::Image`].
pub fn new_png(root: &TokenStream, icon: &Path) -> EmbeddedAssetsResult<Self> {
let buf = Self::open(icon);
let decoder = png::Decoder::new(Cursor::new(&buf));
let mut reader = decoderView on GitHub (pinned to 52e4b6e71d)
Solutions
- Regenerate icons from source with `npx tauri icon app-icon.png`, which emits well-formed multi-size ICO/PNGs
- Re-export the ICO from a mainstream tool (GIMP, ImageMagick) including standard sizes (16/32/48/256)
- Validate the file decodes before building: `magick identify icon.ico` or `pngcheck` on the payload
Example fix
# before # icon.ico parses but entry payload is corrupt -> panic: failed to decode icon # after npx tauri icon ./app-icon.png # regenerates decodable icon.ico cargo build # codegen succeeds
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
# prove every .ico decodes end-to-end before the Rust build
for ico in src-tauri/icons/*.ico; do magick identify "$ico" >/dev/null || { echo "undecodable icon: $ico"; exit 1; }; done Prevention
- Regenerate icons with `tauri icon` whenever the source image changes
- Re-export ICOs only from mainstream tools (GIMP/ImageMagick) with standard sizes
- Treat any icon that was hand-converted once as suspect: re-derive it from the source PNG
When it happens
Trigger: An ICO whose directory header is fine but whose entry payload is corrupt: malformed BMP header, zero width/height, unsupported bit depth, or a truncated image stream produced by a buggy icon converter.
Common situations: ICOs exported by niche online converters; files damaged in transfer or by partial git checkouts; icon variants with exotic compression the ico crate cannot decode.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse icon {}: {}
- The `frontendDist` configuration is set to `{path:?}` but th
- failed to read plist {}: {}
- The isolation application path is set to `{dir:?}` but it do
- The isolation application does not contain a file setting th
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/05726f4c09634c40.
Report an issue: GitHub.