When you install a package on a Linux system, it creates and modifies a set of files on your system. Typically, it isn't possible to move all of those files from one system to another and end up with a functioning program. This is for a few reasons, but a big one is that the system libraries the program depends on will differ between the two versions of Ubuntu.
Since Snaps are more self-contained with their dependencies than programs installed as Apt packages, I'm curious to know what the obstacles are to moving a Snap from one version of Ubuntu to the next when upgrading and still have it work on the new system. Even if it's not possible, figuring out exactly why it's not possible should be as educational as figuring out how to do it.
As an exercise, I'm trying to move a Snap from one installation (Ubuntu 20.04) to another (Ubuntu 22.04). The Snap I'm using to experiment with is Authy, and it was originally installed in the normal way using snap install authy
on the 20.04 system. So far, I've moved the following files and folders from the 20.04 to the 22.04 system:
~/snap/authy/
/snap/authy/
/snap/bin/authy
/var/snap/authy/
as well as everything in /var/lib/snapd/
that has "authy" in its name:
/var/lib/snapd/snaps/authy_12.snap
/var/lib/snapd/snaps/authy_11.snap
/var/lib/snapd/inhibit/authy.lock
/var/lib/snapd/sequence/authy.json
/var/lib/snapd/seccomp/bpf/snap.authy.authy.src
/var/lib/snapd/seccomp/bpf/snap.authy.authy.bin
/var/lib/snapd/cookie/snap.authy
/var/lib/snapd/mount/snap.authy.user-fstab
/var/lib/snapd/mount/snap.authy.fstab
/var/lib/snapd/apparmor/profiles/snap-update-ns.authy
/var/lib/snapd/apparmor/profiles/snap.authy.authy
/var/lib/snapd/desktop/applications/authy_authy.desktop
When I moved ~/snap/authy/
, I also changed all greppable uses of the 20.04 username to that of the 22.04 username. No files in anything else I moved contained a reference to system usernames.
Moving the authy_authy.desktop
file caused the Authy program to appear in the system menu, as you might expect. The executable command associated with this launcher is
env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/authy_authy.desktop /snap/bin/authy %U
Selecting the program from the system menu does nothing. Trying it from the command line (remove the %U
because it doesn't work and isn't needed) results in a boilerplate list of snap commands:
$ env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/authy_authy.desktop /snap/bin/authy
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.
Usage: snap <command> [<options>...]
Commonly used commands can be classified as follows:
Basics: find, info, install, remove, list
...more: refresh, revert, switch, disable, enable, create-cohort
History: changes, tasks, abort, watch
Daemons: services, start, stop, restart, logs
Permissions: connections, interface, connect, disconnect
Configuration: get, set, unset, wait
App Aliases: alias, aliases, unalias, prefer
Account: login, logout, whoami
Snapshots: saved, save, check-snapshot, restore, forget
Device: model, reboot, recovery
... Other: warnings, okay, known, ack, version
Development: download, pack, run, try
For more information about a command, run 'snap help <command>'.
For a short summary of all commands, run 'snap help --all'.
So no error message, but also no functioning Authy program.
That's all of the Authy-Snap-related files I can find to transfer. I'm posting to ask
- Is there something I missed that I should also try moving?
- Is there a concrete explanation of why something like this would never work?
Thanks in advance.
Update
A comment brought up systemd
unit files, which I hadn't considered. I found these Authy unit files:
/etc/systemd/system/snap-authy-11.mount
/etc/systemd/system/snap-authy-12.mount
and corresponding enabled symlinks in
/etc/systemd/system/default.target.wants/
/etc/systemd/system/multi-user.target.wants/
I copied the two unit files between systems, enabled them ($ sudo systemctl enable snap-authy-12.mount
), and reloaded systemd
($ sudo systemctl daemon-reload
). This didn't change the issue; I still get the same boilerplate Snap info from trying to open Authy.
Anyway, I'm giving up on this to focus on other things. Everyone's welcome to post more ideas if the problem interests you, but only if you understand that this is about identifying and moving sets of files, not about running snap install
on a local file.