SNAP_COMMON and experimental.parallel-instances


Thanks for your effort all.

When using the (experimental, but very useful) “snap set system experimental.parallel-instances=true” and launching a new parallel instance, any references to ${SNAP_DATA} or ${SNAP_COMMON} in the install hook returns the instance name, but not the suffix.

snap 2.43.3
snapd 2.43.3
series 16
ubuntu 19.10
kernel 5.3.0-42-generic


There is a comment in the source indicating that those directories are mounted appropriately within the snap’s mount namespace:

If you have the parallel install of your snap write something to $SNAP_COMMON or $SNAP_DATA, have you checked where that data shows up in the host system’s mount namespace?

One way you could test this would be to run sudo snap run --shell mysnap_instance.command, which should give you a root shell in your snap’s namespace, where you can easily write your test files.

1 Like

Thank you for trying out the feature. We have tried to make the parallel instances setup transparent for the applications. We expect the developers to use $SNAP_DATA and $SNAP_COMMON, but in the event that some snap is using a hardcoded the path to /var/snap/<snapname>/{common,<rev>}, the mount namespace of a parallel installed snap is setup such that things should work seamlessly.

As described in Parallel Installs when you snap is named foo_bar, then the following apply:

  • $SNAP_COMMON is set to /var/snap/foo/common and shows the content of /var/snap/foo_bar/common
  • $SNAP_DATA is /var/snap/foo/<rev> and shows the content of /var/snap/foo_bar/<rev>

If you need to know the instance key, there are $SNAP_INSTANCE_NAME and $SNAP_INSTANCE_KEY environment variables. HTH

1 Like