snaps key doesn't allow to specify which channel to use for a snap

Bug #1995101 reported by Alex Murray
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lpci
Fix Released
Low
Simone Pelosi

Bug Description

Some snaps are not available in latest/stable - as such, when trying to use such a snap via the snaps key in .launchpad.yaml the job will fail with something like:

Running `snap install black`
lpcraft internal error: SnapInstallationError(brief="Failed to install/refresh snap 'black'.", details='* Command that failed: \'lxc --project lpcraft exec local:lpcraft-tree-523579-focal-amd64 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin http_proxy=http://10.10.10.1:8222/ https_proxy=http://10.10.10.1:8222/ snap install black --channel latest/stable --classic\'\n* Command exit code: 1\n* Command standard error output: b\'error: snap "black" is not available on stable but is available to install on\\n the following channels:\\n\\n beta snap install --beta black\\n edge snap install --edge black\\n\\n Please be mindful pre-release channels may include features not\\n completely tested or implemented. Get more information with \\\'snap info\\n black\\\'.\\n\'', resolution=None)

In this case, if it was possible to specify the channel to use for the snap, ie say 22/stable then it would install correctly.

For a more complete example of this failure, see https://code.launchpad.net/~alexmurray/review-tools/+git/review-tools/+build/13576 from the second commit in this merge proposal - https://code.launchpad.net/~alexmurray/review-tools/+git/review-tools/+merge/432318

Also I notice this runs snap install with --classic even though in this case the snap in question does not use classic confinement. Ideally a snap would only be installed with --classic if it actually declared "confinement: classic"

Related branches

Revision history for this message
Jürgen Gmach (jugmac00) wrote (last edit ):

Hey Alex,

thanks for your report.

Indeed, both the channel and the classic option are currently hardcoded as there was no need for configuration yet, also see https://git.launchpad.net/lpcraft/tree/lpcraft/commands/run.py#n477

The upstream library we use supports both options, so this should be a straightforward enhancement for lpcraft.

I saw you install the Snap manually as a workaround, so I think this is a reasonable, but not an urgent task.

I have two additional suggestions:
- As our colleague Sergio is the maintainer of the Black snap, it could make sense to ask him to create a `latest/stable` channel for Black.
- I was curious why you want to install Black as a Snap, so I cloned your repository and had a look, and I saw that you use a Makefile. This seems to be widely used for developing Python packages at Canonical, but rarely seen elsewhere. Since a couple of years most projects have adopted https://pre-commit.com/ to install, run and manage all linters. In case you are interested to learn more about the many advantages of pre-commit, we can sit down together next week in Prague.

That said... enhancing the build experience is on our next roadmap, so we should be able to allocate some time for this issue.

Jürgen Gmach
Launchpad team

Changed in lpcraft:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Jürgen Gmach (jugmac00) wrote (last edit ):

Update: Thinking about it, my first suggestion does not make much sense, as you certainly want to have a fixed version for linters, otherwise CI or a linter run at any of the developer boxes could break any time when a new version of the linter was released, without changing the configuration.

Simone Pelosi (pelpsi)
Changed in lpcraft:
assignee: nobody → Simone Pelosi (pelpsi)
Simone Pelosi (pelpsi)
Changed in lpci:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.