Although the current answers at https://askubuntu.com/q/1268615/1002900 explain how to install versions of applications which provide channels for specific versions, this isn’t applicable for most, and doesn’t actually answer how to install a specific version of a snap package on a channel instead of how to track a different channel.
I ask because for diagnostic purposes — usually creating bug reports, but also when specific package version is programmatically useful — I need to be able to choose a specific version irrespective of the channels available.
As an example,
snap install powershell --channel=latest/stable
shall currently install 7.4.1, but when that changes, the command no longer installs 7.4.1. This package does not provide versioned channels. How do I force it to forever install 7.4.1?
For comparison, I can install a specific version of a Flatpak package using
As a developer of a given snap you can install any of the versions that were ever uploaded to the store.
As a user you can only install a version that is published to a channel, track or branch, but you cannot choose an arbitrary revision.
In practice, if someone wants to offer an experimental build they can use non-stable channel such as edge or beta. If someone wants to offer a feature build it can be done by publishing the snap to a named branch. Any such branch may be used for testing but will automatically close after 30 days IIRC.
EDIT: To expand on my answer. If you need longevity you should requests tracks, so that users may pick the track they want to install from. For instance you may offer track with 7.4 or even 7.4.1.
In that case, manually downloading all available versions and applying them using https://askubuntu.com/a/1483150/1002900 might be the sole way to use arbitrary versions as a user.
If you want to you can snap download all the revisions and host them somewhere. It may be useful to host both the .snap and the .assert file and to hold the snap so that it does not refresh.
Will yield you revision 605 installed, and will never refresh. Caution is advised though, because the lack of auto refresh will mean no security/updates at all.
@jnsgruk, where is this documented? I’d like to know how to ascertain which version corresponds to which “revision”. (snap info powershell | Select-String 'rev' outputs nothing.)
I ask not least because whether revisions are channel-specific is not obvious to me. Could you clarify that too? It doesn’t output any errors, and correctly identifies that that is the version installed.
Revisions are assigned when a blob is uploaded to the store and are not channel specific. You may never publish a revision to any channel or publish the same revision to all the channels.
As for your question, I think that would install that specific revision while tracking latest/stable:
zyga@novigrad:~$ sudo snap install powershell --classic --channel=latest/stable --revision 264
[sudo] hasło użytkownika zyga:
powershell 7.4.1 from Microsoft PowerShell✓ installed
zyga@novigrad:~$ snap info powershell | grep tracking
tracking: latest/stable