Disconnected interfaces don't re-connect when a snap is removed and, subsequently re-installed

I would expect a re-installed snap to always connect interfaces as it originally did, even if the interface was disconnected when the snap was removed. I encountered a problem with the following scenario:

  1. Install a snap (from the https://snapcraft.io/store) that interfaces to “:network” when installed.
  2. Use “snap connections” or “snap interfaces” to confirm connection to “:network”.
  3. Disconnect the interface via “snap disconnect snapname:network”.
  4. Use “snap connections” and “snap interfaces” to confirm the connection to “:network” no longer exists.
  5. Remove the snap: “snap remove snapname”.
  6. Install the snap: “snap install snapname”.
  7. Both “snap connections” and “snap interfaces” show NO connection to “:network”.

This happened with or without the “–devmode” flag when installing.

This scenario was executed on Ubuntu 16.04 LTS with both the core snap and core18 installed.

Seems like a bug to me.

I just noticed the same thing, with some other plug paratext-10-studio:gnome-3-28-1804 on some other snap. Before, the connections looked like below. After disconnect/remove/install the connection was absent, and I needed to manually connect, and now I’m stuck with a manual connection (as shown in the Notes column of snap connections). How do I get back to a clean slate, where the plug is auto-connected on install?

❯ snap connections paratext-10-studio
Interface                 Plug                                         Slot                             Notes
audio-playback            paratext-10-studio:audio-playback            :audio-playback                  -
browser-support           paratext-10-studio:browser-support           :browser-support                 -
content[gnome-3-28-1804]  paratext-10-studio:gnome-3-28-1804           gnome-3-28-1804:gnome-3-28-1804  -
...

So it looks like snap remove ... --purge solves this. So apparently indented behavior is that remove by default saves a snapshot of the state, and a re-install then picks that up.

However, I had done snap disconnect + snap connect, and after remove/install the plug was disconnected. So there is some bug, I guess, around saving a snapshot of connections and then re-connecting on re-install…

It’s an intended behavior, snapd has a memory that tends to be sticky. You can see this hidden in the snap disconnect help:

When an automatic connection is manually disconnected, its disconnected state
is retained after a snap refresh. The --forget flag can be added to the
disconnect command to reset this behaviour, and consequently re-enable
an automatic reconnection after a snap refresh.

[disconnect command options]
      --no-wait          Do not wait for the operation to finish but just print the change id.
      --forget           Forget remembered state about the given connection.

I’d say it would be useful if remove also had this flag, so perhaps it’s a papercut.

1 Like