tauri-apps/tauri · error
failed to parse icon {}: {}
Error message
failed to parse icon {}: {} What it means
Compile-time panic in tauri-codegen's icon handling (tauri::image module used by generate_context!). new_ico reads the .ico file into memory and hands it to ico::IconDir::read; if the bytes are not a parseable ICO container (bad header/magic, truncated file), it panics with the icon path and the parse error.
Source
Thrown at crates/tauri-codegen/src/image.rs:55
}
}
/// Cache the icon without any manipulation.
pub fn new_raw(root: &TokenStream, icon: &Path) -> EmbeddedAssetsResult<Self> {
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(),
},
})
}
View on GitHub (pinned to 52e4b6e71d)
Solutions
- Regenerate the full icon set from a single square PNG source: `npx tauri icon path/to/icon.png`
- Verify the real format: `file icons/icon.ico` should report 'MS Windows icon resource'
- Replace the corrupt file with a valid ICO produced by a proper converter (ImageMagick/GIMP)
Example fix
# before file src-tauri/icons/icon.ico # 'PNG image data' -> panic: failed to parse icon # after npx tauri icon ./app-icon.png # regenerates valid icons incl. icon.ico file src-tauri/icons/icon.ico # 'MS Windows icon resource'
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
for ico in src-tauri/icons/*.ico; do
file "$ico" | grep -q 'MS Windows icon' || { echo "not a valid ICO: $ico"; exit 1; }
done Prevention
- Generate the whole icon set with `npx tauri icon <png>` instead of sourcing icons manually
- Verify icon files with `file`/`magick identify` in CI
- Pull git-LFS objects before building if icons are stored in LFS
When it happens
Trigger: A file listed in bundle > icon that has an .ico extension but is not actually an ICO: a renamed PNG/JPEG, an HTML error page saved as icon.ico, a git-LFS pointer file, or a truncated download.
Common situations: Downloading icons from the web and trusting the extension; LFS not pulled on CI; manual conversion that produced an empty/corrupt file.
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 decode 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/1b5b0cea1841297a.
Report an issue: GitHub.