My Snapcraft (Preview) for Windows Feedback

I’ve just given the Snapcraft for Windows preview a quick go, and generally I’ve got to say it’s quite nice, but I just thought I’d give some generalised feedback to hopefully be helpful.

Building locally with Multipass works fine but I think could have some improvements.

Firstly, Multipass isn’t installed implicitly by running snapcraft itself, maybe there’s some scope to rely on winget and attempt winget install Canonical.Multipass going forward ( Winget will be rolling out as a standard Windows component in the next few weeks :wink: ).

Manual Multipass installation aside, there was a need to also run multipass set local.privileged-mounts=true which wasn’t spelled out, the build process will reference it and it’s Googlable enough to fix, but presumably snapcraft could check this variable upfront and be more explicit about needing it rather than finding out half way during the build itself.

Finally, one of my snaps uses the dump plugin and an executable bash file. This gets copied over to the Multipass side without the executable bit, which means that the resulting snap fails to build. While some overrides to mark it as executable specifically could be helpful here, it’d be nice if this just worked magically like it does being built on Linux natively.

Remote-build works as expected, aside from the small problem of it outputs some characters that didn’t render in Windows Terminal (as in the new modern Windows Terminal app).

The metrics command mostly works as expected. There appears to be a lot of conditions where the command will error and crash complaining about not having exclusive access to a temporary file, which can be triggered by viewing some long metrics that are piped to more, such as users by country, or specifying --start and --end ranges.

Some commands like snapcraft create-key could probably have their errors changed to something more suitable. They currently print that the snapd snap isn’t installed which is unlikely to ever be an appropriate solution for Windows.

Ultimately, I think this is in a good position. Although I’m happy to help out around here with some snaps on the side, I’m a Windows exclusive user for the most part (The nephews need their Fortnite and Roblox!), so for me in particular, the combination of Multipass/Snapcraft/Winget brings a lot of nerdy joy, and when I get around to setting up my environment again for Windows 11, the Windows release of snapcraft might help replace my current flow of having to mess with HyperV VM’s manually. A cloud-init file to make Multipass have RDP by default for testing might be all that remains from me avoiding using HyperV directly itself, which would be ideal because it appears that Microsoft are moving away from desktop use of HyperV directly to focus on WSLg. (e.g, by deprecating their support for enhanced sessions).

1 Like

This is excellent feedback, thank you! We should use this as a starting point for “Known Issues” documentation :smiley:

Did Snapcraft ask you to install it? We will have to look into winget…

Agreed. This is a new change in Multipass we need to account for.

This is a known issue, but if anyone knows of a good way to way handle this, I’m all ears! :wink:

Will need to triage/fix, thanks!

Will need to triage/fix, thanks!

Good point, will add to list, thanks!

:smiley:

1 Like

It asked to manually install Multipass, saying that the version upstream was newer than the version it knew about, so I assume it might be trying to automatically install generally but failed for me here.

The overlap of Winget supported Windows versions and Multipass supported Windows versions looks pretty comparable to me. From what I remember the Winget general rollout is due ~september/october and should just appear on peoples machines as if by magic, so although it’s relatively niche now it’ll be literally baked into future Windows ISO’s and dependable for users to have by default in the future.

Probably not the best solution because there’ll be corner cases even this misses, but since the problem exists in files that are in the project directory itself, they’d likely be under version control, and Git would store the state of the executable bit in the commit history, so you could possibly run the following on the build side which I hope would recover some of the missing executable bits.

git diff -p -R --no-ext-diff --no-color \
    | grep -E "^(diff|(old|new) mode)" --color=never  \
    | git apply

(Stolen from https://stackoverflow.com/questions/2517339/how-to-restore-the-permissions-of-files-and-directories-within-git-if-they-have)

It’s not ideal since it will miss files that aren’t known to Git, and not everyone will be using Git, but maybe it’ll reduce the frequency of the problem.

2 Likes

Hello I am building my Snap package on Linux with core 20 as base. Is it possible to run snap services on windows yet?

Snaps are a packaging format for Linux, I’d never expect them to run natively on Windows. The best you’d be able to do is to run them in a virtual machine.

Snapcraft for Windows is about building snaps on Windows (again, also in a VM) rather than actually running them there.

Take a look at https://multipass.run/ for a nice Ubuntu focused VM toolkit.

1 Like

So I take it that it is also not possible to run Snap on MacOS?

MacOS unfortunately is also unlikely to ever work as a run-time environment. Again, if you needed Snaps specifically I’d recommend using a Virtual Machine. Of course, if you have specific use cases for specific snaps, there might be other solutions available (other package managers for the OS, Docker, etc).