"cups" interface merged into snapd - Additional steps to complete

Update: snapd 2.55.2 is NOT in the stable channel. Seems that it got accidentally promoted and withdrawn right after. Therefore I have commented out the assumes: [snapd2.55] line in the snapcraft.yaml of the CUPS Snap now.

snapd 2.55.2 made it into the Stable channel and I have added the assumes: [snapd2.55] line to the snapcraft.yaml of the CUPS Snap, so the TODO List above is completed.

The Pull Request to fix the bug of CUPS_SERVER always being set to /var/cups/cups.sock regardless of cups plugged or not which I mentioned two posts earlier here got merged and you get the fix included if you upgrade your snapd to the one on the Edge channel:

sudo snap refresh --edge snapd

(Must be 2.55.2+git188.ge21669c or later, check with snap version or snap list)

This fixes the bug for both the CUPS Snap and Snaps plugging cups-control. My earlier assumptions that the latter are not covered was wrong.

I have tested the fix intensively (see my comments in the PR starting here) and with the workaround described below everything is working as designed!

So principally we are ready to go with the cups interface, but there is still a little problem when updating to the fixed snapd. If a Snap, especially the CUPS Snap has the environment variable set and after that we update snapd and restart the CUPS Snap, the variable stays set. There is some kind of cache pertinent through restart of the Snap.

To clean up this, once having updated snapd to the Edge version, run

sudo /usr/lib/snapd/snap-discard-ns cups

and the variable gets immediately cleared so that you can use the CUPS Snap and its cups interface correctly from now on.

Also all your Snaps which plug cups-control need this clean-up as otherwise you cannot print from these Snaps. Note that there are several, as cups-control was the interface used up to now also if one just wants to print. Run the following command for each Snap:

sudo /usr/lib/snapd/snap-discard-ns SNAPNAME

replacing SNAPNAME by the name of the Snap to fix. Run

snap connections | grep cups-control

to find all your installed Snaps which plug cups-control.

You need to run snap-discard-ns on your Snaps only once and never again, only when you update from a still buggy snapd from version 2.55 on and older than 2.55.2+git188.ge21669c to a fixed version, 2.55.2+git188.ge21669c or newer.

So we hae now the following new TODO list:

To be done as soon as possible:

  • Create an automated way to get rid of the CUPS_SERVER environment variable wrongly set by a buggy snapd, for example let snapd (snap-exec) unset the CUPS_SERVER environment variable if it finds that the /var/cups/ directory is not bind-mounted meaning that cups is not plugged, so when not setting CUPS_SERVER=/var/cups/cups.sock unsetting CUPS_SERVER. Or do a snap-discard-ns on all installed Snaps every time snapd is updated.
  • Sort out the snapd 2.55.x release into the stable channel.

To be done during the coming weeks/months:

  • Let snapd directly auto-install the CUPS Snap when we are installing a Snap which plugs cups, without the currently used placeholder content interface. This way a snapper only needs to add cups to the plugs of an app so that it can print, nothing more. No ugly content interface entry needs to be added then.
  • Let snapd be able to set environment variables triggered by plugging a given interface (and remove them if the interface is not plugged any more). This way we can get rid of the current workaround of checking for the bind mount on /var/cups/ and we can set environment variables also for other interfaces, where the use of them cannot get detected that easily.

@mvo thanks a lot for your cooperation with me to debug the CUPS_SERVER environment variable issue, for posting the PR, and for adding the long-term TODOs to the current developemnt cycle, and thanks @cachio, @mardy, and @pstolowski for approving the PR so quickly.

1 Like