Help with desktop file not being primed

Hello. I have a snapcraft.yaml file along with a sibling ‘gui’ folder here:

It used to automatically install the .desktop file (and png) but for some reason the prime/meta dir is empty now except for the snap.yaml. The docs indicate

“When you run snapcraft , the entire contents of snap/gui will be copied into the meta/gui/ folder of the resulting snap.”

If I manually copy the files to prime/meta/gui (in the VM shell), and then run snapcraft, it appears to remove the .desktop file. I tried installing the resulting snap (in Ubuntu) just to be sure… but no .desktop file in /var/lib/snapd/desktop/applications/

The odd thing is this used to work. I’ve probably bunged something up, but no idea what. Using snapcraft 4.4.1 stable with core20.

Thanks for any help.

Not sure I understand the issue. I just cloned your repo, built using snapcraft --use-lxd and installed and ran the snap. It has a valid desktop file, and can launch from the command line and from the desktop.

Well, thank you popey for doing that! Huh. I am using multipass… maybe I’ll try lxd instead. So strange.

It must be something local wrong with my build machine. Tried with lxd. No diff. It snaps fine, but the generated snap does not launch from desktop etc. Installing previous version/snap of the app works fine. In any case, thanks again for testing… knowing where to look really helps (will prob start by re-cloning). Cheers.

I’m still stuck on this TBH. I tried a clean clone, tried a ‘snapcraft clean’, tried the edge version of snapcraft (4.4.2) as well as stable, tried more liberal file permissions on the gui folder and contents. All to no effect.

I assume the gui dir should end up in prime/meta (but it doesn’t)
If I manually copy the gui dir from ‘parts’ into prime/meta (in the VM shell) and then type snapcraft, the spinner spins and afterwards the .desktop file is gone (although the .png is still there). I assume that’s not expected behaviour?

My current kinda hacky workaround is to a) mount the resulting snap using sudo mount -t squashfs -o ro … b) dupe it, unmount, move the original snap away c) copy the gui folder in there (with the missing desktop file) d) Resquash it with something like:

mksquashfs mnt2/ tacentview_1.0.16_amd64.snap -noappend -comp xz -all-root -no-xattrs -no-fragments

Most of the above, including the dupe (cp -r), needs to be done with sudo.

It’s not elegant, but works :wink:

Are you by chance building it from inside the snap directory, instead of above it? If you’re inside the snap directory snapcraft won’t see snap/gui, just gui which will be ignored.

An unfortunate side-effect of allowing snapcraft.yaml to reside in <project> directory or <project>/snap.

1 Like

That’s exactly what I was doing!
Can’t believe I didn’t catch that… it’s just that so much worked just fine. Thank you cjp256.

1 Like

well, i guess snapcraft knows where it is running so perhaps spitting out a warning about this issue would be a good thing ?

1 Like

A warning would certainly have saved me some embarrassment :wink:

1 Like

Yes, it would :smiley:

Well it won’t help you now, but maybe the next one!

PR to add a warning:

E.g.: Snapcraft is running in directory 'snap'. If this is the snap assets directory, please run snapcraft from /home/chris/tmp/tacentview/Linux/snapcraft.

Feel free to suggest an improvement :smiley:

1 Like