invalid icon path '$SNAP/meta/gui/icon.png'. Should either specify the basename of the file (with or without file extension), snap.<snap name>.<snap command>[.(png|svg)] or ${SNAP}/path/to/icon.(png|svg) lint-snap-v2_desktop_file_icon (hw-probe.desktop, $SNAP/meta/gui/icon.png)
Why? How to fix this?
Desktop file is:
[Desktop Entry]
Name=Hardware Probe
Comment=Probe for hardware and upload result to the Linux hardware database
Exec=hw-probe
Icon=$SNAP/meta/gui/icon.png
Terminal=true
Type=Application
StartupNotify=true
Categories=System;
Keywords=HW Probe;Hardware;Probe;
Simply changing it to ${SNAP}/meta/gui/icon.png would likely have been sufficient.
The desktop file sanitisation routines in snapd only expand ${SNAP} and not $SNAP, so it is likely that your old icon line wasn’t being expanded correctly either. All that has changed is that the review tools have been updated to catch this mistake.
Snapcraft prefers that you don’t prefix with ${SNAP} any more. While it will work, the preferred method is to use /usr/share/icons/hw-probe.png when your icon is in that location by considering the snap root as /. This makes it easier to support unmodified desktop files from the upstream projects, where for example if you were to use autotools and set --prefix=/usr it will install the icons relative to /usr and set their location in the desktop file (provided the autotools project is configured to do so) with the path beginning with /usr and it will “just work”.
In terms of the review-tools and the upcoming PR from @jamesh, meta/snap.yaml (as opposed to snapcraft.yaml), cannot use absolute paths. I understood that snapcraft will translate /usr/share/icons/hw-probe.png in the snapcraft.yaml into ${SNAP}/usr/share/icons/hw-probe.png in the resulting meta/snap.yaml. @lucyllewy and @sergiusens - is this the case? I can adjust the message accordingly based on your feedback.