Update
Summary
In January, we wrote this post to explain the introduction of an experimental hidden-snap-folder
flag that allows users to opt-in to move their ~/snap folder into ~/.snap/data. Our post also described a plan to eventually relocate snap home directories to a location under ~/Snap.
During our 22.10 roadmap planning sprint, we reconsidered parts of our ~/snap strategy, and this means that snaps refreshing to the new and latest core22
base will not automatically migrate ~/snap into either ~/.snap/data or ~/Snap, at least for now. More details on this can be found below.
Our new plan is to introduce an additional experimental flag to enable migration to ~/Snap only for a list of specific snaps. This isn’t an automatic migration, but we still wanted to let users easily test the potential migration feature. With that in mind, we’ve also added a debug command to safely migrate snaps’ home directories.
Note that the original experimental hidden-snap-folder
flag remains and still allows users to move ~/snap for core20- and core18-based snaps to ~/.snap/data.
Previous plan
Our original plan was to migrate snap home directories into a sub-directory of ~/Snap. Each new directory would be initialised with the contents of a snap’s revisioned directory, used previously as its home directory. However, there would be no revisioning in the new location going forward. This change would meet our objectives of 1) hiding the data that a snap may place in its internal directories, while 2) still providing a cleaner and tidier location for users to interact with snap user-facing data.
Another objective that we had was to minimise migration pains for both snap users and developers. To help here, we decided to migrate snaps to the new home directory during their first refresh to a core22
base. Each snap is obviously configured differently, and some might do things that affect the home migration or its subsequent operation (e.g., mapping the HOME environment variable to a custom location, using SNAP_USER_DATA and HOME interchangeably). Therefore, it was crucial that migrated snaps were tested under the new environment. Migrating during a refresh to a new base was intended to minimise the effort required by snap developers, since they’re most likely already testing their snaps with the new base anyway.
New plan in detail
Considering we want to provide users and developers with the time and opportunity to experiment with the new snap home location, we have decided to not migrate snap home directories with the core22
base refresh.
Instead, we have introduced a new experimental flag and debug command that allow users to opt-in to the new environment. The feedback we get from snap users and developers will inform our decisions on how we deal with the new home directory in the future. Options we want to consider include:
- Allowing snaps to opt-in to having their home directory under ~/Snap via a setting in their
snap.yaml
or snapcraft.yaml
. This leaves the decision to migrate in a snap developers’ hands and allows them to test their snaps with the new home location before releasing them to users.
- Automatically migrate snap home directories to a location under ~/Snap when a snap refreshes to a revision that uses the
core24
base. This would also allow snap developers to test their snaps with the new home location before they reach users.
- Automatically migrate all snaps at some yet-to-be-determined point. Before this becomes feasible, we’d need to know that there was very little risk of snaps breaking due to the home directory change.
- Don’t migrate snap home directories at all.
None of this affects the first part of the plan. The experimental hidden-snap-folder
flag will remain for the foreseeable future, allowing users the option to move ~/snap to ~/.snap/data, effectively hiding it. This will eventually be made into the default behaviour, unless a compelling reason not to do it is discovered during the ongoing experimental phase.
Using the new experimental flag
For the new experimental flag and debug command, there are two steps required to manually trigger the migration of the home directory to a location under ~/Snap.
First, as the feature is experimental, you must first acknowledge this by enabling a feature flag. You can do that with the following command:
sudo snap set system experimental.move-snap-home-dir=true
Second, initiate the migration by running the following command debug command:
sudo snap debug migrate-home <snap1> <snap2>...
This process will generate a change that creates a directory under ~/Snap and initialises it with the contents of the previous (versioned) home directory.
Exceptions which are not copied include some of the default directories in the XDG Base Directory Specification, in particular .config
, .local/share
and .config
. These files remain in the original revisioned location and their respective environment variables will remain set to these original locations after the migration has completed.
The exceptions are to avoid the new home directories becoming overwhelmed with configuration files, making them confusing for users who wish to interact with their application data.
Note that this can be done with or without the hidden-snap-folder
feature as the two experimental options are wholly independent of each other.