snap install fails if multiple .snap files of the same snap are specified on the command-line

Bug #2049476 reported by Thomas Perl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
New
Undecided
Unassigned

Bug Description

I accidentally called "snap install" with two versions of the same local snap I'm building, because I was using glob expressions, and there was an old package version in the current directory.

Note that this might require a previous version of "mypackage" to be installed.

> % sudo snap install ./mypackage_*.snap --classic --dangerous

Assuming mypackage_0.0.1_amd64.snap and mypackage_0.0.2_amd64.snap (having the same "name" in the metadata) are in the current directory, I get the following error:

> error: cannot perform the following tasks:
> - Remove data for snap "mypackage" (x18) (cannot find snap "mypackage" at revision x18)

Specifying the same file twice (same filename) is handled correctly by "snap install":

> % sudo snap install ./mypackage_0.0.1_amd64.snap ./mypackage_0.0.1_amd64.snap --classic --dangerous
> mypackage 0.0.1 installed

This issue can even be reproduced by just symlinking the same snap to a different name, so it doesn't even have to have different contents:

> % ln -s ./mypackage_0.0.1_amd64.snap foo.snap
> % sudo snap install ./mypackage_0.0.1_amd64.snap ./foo.snap --classic --dangerous
> error: cannot perform the following tasks:
> - Remove data for snap "mypackage" (x21) (cannot find snap "mypackage" at revision x21)

While getting this error, it DOES install the first package correctly, but fails installing the "second" package (foo.snap, which is a symlink to the same file as the first package).

The expected result would be either:

 - for snap to not install anything and error out immediately ("You specified multiple snaps of the same name on the command line"), or
 - install only the last specified file on the command line (and warn that one or more snaps of the same name have been ignored?) or
 - to install the packages in the order they appear on the command-line (i.e. install the first snap, then install the second snap over the first one, without failing)

As an additional datapoint how similar tools handle this case, specifying two ".deb" packages to "dpkg -i" will unpack one and then the other, but only configure it once (of course, this concept doesn't apply 1:1 to snap, but at least it handles specifying a package multiple times more gracefully at the moment). "dpkg -i" with multiple .deb files that have the same package name does however print a warning:

> More than one copy of package mypackage has been unpacked
> in this run ! Only configuring it once.

Thomas Perl (thp)
description: updated
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.