As a snap owner, not able to download a snap by revision

I can only refresh but not download, it seems a bug to me.
Before login, a user cannot download or refresh by specifying a revision

$ snap info dmidecode-tool                   
name:      dmidecode-tool
summary:   SMBIOS/DMI table decoder
publisher: Rex Tsai (chihchun)
contact:   https://github.com/chihchun/dmidecode-snap/issues
license:   GPL-2.0+
description: |
  Dmidecode reports information about the system's hardware as described in the
  system BIOS according to the SMBIOS/DMI standard.
  .
  This information typically includes system manufacturer, model name, serial
  number, BIOS version, asset tag as well as a lot of other details of varying
  level of interest and reliability depending on the manufacturer. This will
  often include usage status for the CPU sockets, expansion slots (e.g. AGP, PCI,
  ISA) and memory module slots, and the list of I/O ports (e.g. serial, parallel,
  USB).
  .
  Beware that DMI data have proven to be too unreliable to be blindly trusted.
  Dmidecode does not scan the hardware, it only reports what the BIOS told it to.
snap-id: AjauNTwGxi02ma3W2S7eq0xlCi7gEgge
channels:
  stable:    3.0 2018-05-15  (3) 77kB -
  candidate: ↑                        
  beta:      ↑                        
  edge:      3.0 2018-12-24 (15) 61kB -
$ snap install dmidecode-tool                   
dmidecode-tool 3.0 from Rex Tsai (chihchun) installed
$ snap whoami                
email: -
$ sudo snap refresh --revision=4 dmidecode-tool
error: cannot refresh "dmidecode-tool": Access by specifying a revision is not allowed for this
       Snap.
$ sudo snap download --revision=4 dmidecode-tool
Fetching snap "dmidecode-tool"
error: cannot download snap "dmidecode-tool": Access by specifying a revision is not allowed for this Snap.

But after I login, I can only refresh but not download. (refresh will download the snap)

$ snap whoami
email: rex.cc.tsai@gmail.com
$ sudo snap download --revision=4 dmidecode-tool
Fetching snap "dmidecode-tool"
error: cannot download snap "dmidecode-tool": Access by specifying a revision is not allowed for this Snap.
$ sudo snap refresh --revision=4 dmidecode-tool 
dmidecode-tool 3.0 from Rex Tsai (chihchun) refreshed

Is this an expected behavior?

It is expected. The reason is that “snap download” bypasses the snapd daemon, while “snap refresh” instructs snapd daemon to perform the refresh. And the key issue here is that your credentials are accessible to snapd, but not to the snap command itself.

I think there are bugs filed for this (like this one) but for now - yes, what you’re seeing is expected.

  • Daniel
1 Like

As a workaround, you should be able to download old revisions through the dashboard.snapcraft.io website.

Yes, this is how snap download works for the reasons @roadmr mentioned. What you can do is follow this post Improvements in snap download, particularly the last comment, and you can export proper credentials from snapcraft and use them to run snap download (I’m assuming you need the assertions besides the snap itself, right?).

Cheers, Natalia.

Thanks, I’m able to use UBUNTU_STORE_AUTH_DATA_FILENAME and UBUNTU_STORE_ID to download the snap from a brand store.

As a user, just confused by why “snap download” has different behavior to “snap refresh” from the permission perspective.

Improvements in snap download covers it

1 Like

Can you download the assertion from the dashboard too? I couldn’t see how in a few seconds of clicking.

It’s not possible to download the assertions from dashboard.snapcraft.io. But the “snap digest” from the dashboard revision page is the information you need to ask snapd to find it for you:

$ snap known --remote snap-revision snap-sha3-384=WaI8pVYpIDnfhvgFGr2pTT_qZxy61Lnv98WR7RAEkOGI7y1iAAZIYoCdlhdeocTD

2 Likes