Skip to content

[Bug] --system-tray-icon ships a missing icon path when the copy fails (and a dead pathExists check) #1302

Description

Bug

In mergeIcons (bin/helpers/merge.ts), the custom system tray icon handling has two defects:

await fsExtra.pathExists(options.systemTrayIcon);   // result discarded (dead)
const iconExt = path.extname(options.systemTrayIcon).toLowerCase();
if (iconExt === '.png' || iconExt === '.ico') {
  const trayIcoPath = path.join(npmDirectory, `src-tauri/png/${safeAppName}${iconExt}`);
  trayIconPath = `png/${safeAppName}${iconExt}`;   // assigned BEFORE the copy
  await fsExtra.copy(options.systemTrayIcon, trayIcoPath);
}
...
} catch (err) {
  logger.warn(`✼ ...`);
  logger.warn(`✼ Default system tray icon will remain unchanged.`);   // but it already changed
}
  1. Dead checkawait fsExtra.pathExists(...) is awaited but its boolean result is never used.
  2. Premature assignmenttrayIconPath (which becomes system_tray_path in the config) is set before fsExtra.copy. If the source is missing or the copy throws, the catch warns that the default "will remain unchanged", but the config already points at png/<name>.<ext> — a file that was never written. The app then references a non-existent tray icon.

Fix

Use the existence check to keep the default (with a clear "not found" message), and assign trayIconPath only after a successful copy. PR attached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions