Currently a user can snap install foo, getting the snap from the store, and then snap try foo/ and have the snap be in “trymode”:
~/src/httpie-snap/stage$ sudo snap install http
http 0.9.6-0 from 'chipaca' installed
~/src/httpie-snap/stage$ sudo snap try
http 0.9.6-0 mounted from /home/john/src/httpie-snap/stage
it does not end well:
~/src/httpie-snap/stage$ snap list http --all
Name Version Rev Developer Notes
http 0.9.6-0 19 chipaca disabled,try
http 0.9.6-0 x1 try
note how trymode applies to the whole snap. This is because in the state the flag is stored at the snap level, and not in the sequence. Fortunately snapd doesn’t use the flag other than for informative purposes (a snap revert http drops the flag), but I’m pretty sure this whole area is an untested corner case.
It gets worse: we’re going to need to store the original directory used for snap try, to detect at runtime whether the directory (still exists and) is encrypted; if we don’t store this in the state we’d need to go look at the mount unit, which feels like the wrong approach. If we store it in the sequence we now need to either use a new Info-like struct as the Sequence, or add SnapPath to SnapInfo, neither of which is really palatable as things stand.
So, I propose we block mixing try and non-try snap installs. If a snap is installed and you snap try it, you get told to remove it first (and viceversa). This way the current TryMode flag in state is correct, and we can store SnapPath next to it and it still makes sense. A use case for mixing try and non-try is to try out migrations, which if we want to support we could add an explicit flag to try so it copies data before removing the old non-try snap.
Thoughts?