5

I have a PC running Ubuntu 22.04 that I sometimes run headless and connect to through VNC (TigerVNC server, xfce4 desktop). Since upgrading from 20.04 to 22.04, some of my applications, such as Firefox and Inkscape have changed to Snap. Normally, when I use my PC with a monitor and keyboard and mouse, all still works fine, but when connected through VNC, I can no longer open these applications. In the GUI Applications menu, they've just disappeared, and when I try to start them from the command line, I get the following error:

/system.slice/system-vncserver.slice/vncserver@1.service is not a snap cgroup

Searching online, I found a possible solution here:

xhost +
env DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus firefox

but unfortunately I was unable to get this to work (the xhost + part seems to work as it should, but the command after that just gives me the same error about not being a snap cgroup). This may have to do with my $XDG_RUNTIME_DIR not being set, but I'm not sure how to solve that.

In another post, related to a similar issue, the answer (https://askubuntu.com/a/1419532/1646198) suggests to disable cgroups, citing this discussion, but this answer also mentions "many permission denied errors", so I'm not sure whether this would be the way to go.

Does anyone know how to fix this properly?

EDIT: When I substitute $XDG_RUNTIME_DIR in the above env command with /run/users/1000, Firefox starts, but with a ton of "permission denied" errors:

update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gimp/2.0/help /usr/share/gimp/2.0/help none bind,ro 0 0): cannot open directory "/var/lib": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/xubuntu-docs /usr/share/xubuntu-docs none bind,ro 0 0): cannot open directory "/var/lib": permission denied
[Parent 122148, Main Thread] WARNING: Unable to connect to ibus: Could not connect: Connection refused: 'glib warning', file /build/firefox/parts/firefox/build/toolkit/xre/nsSigHandlers.cpp:167

(firefox:122148): IBUS-WARNING **: 16:13:46.960: Unable to connect to ibus: Could not connect: Connection refused

EDIT 2: Even with monitor, keyboard and mouse attached, things don't run as they used to: when I right-click an SVG-file and select 'Open with Inkscape', the Ubuntu spinner shows up for a while, and then... nothing happens. I can now only open SVG-files directly from Inkscape (i.e. first start Inkscape, then use File - Open..., or Ctrl-O).

Any ideas anyone?

Sita
  • 95

3 Answers3

1

Workaround: Use apt versions of those apps instead of snap version.

For Firefox, follow this answer. For Inkscape, run the commands

sudo snap remove inkscape
sudo apt install inkscape

EDIT: To get the most recent version of Inkscape through apt, the Inkscape ppa is helpful:

sudo add-apt-repository ppa:inkscape.dev/stable
sudo apt update
sudo apt install inkscape
Sita
  • 95
1

In my case, the accepted answer did work, but I want to demonstrate an alternative method using Firefox from Snap. The service was of type forking for the user giulio, but for Snap, it presents the same problem as using sudo. I resolved it by:

su giulio
# enter password

And then starting Firefox from that session.

Overall, by switching to the correct user before starting Firefox, you ensure that the application runs within the correct user context with the necessary permissions and access to resources, resolving the issues you encountered with starting Firefox through the systemd service.

Giulio
  • 111
0

I have this same problem with running Python Ruff in a VPS instance. Ruff is not available on apt, it's only packaged in a snap. So, it runs into the same problem:

$ ruff
/system.slice/ssh.service is not a snap cgroup

There is a bug report about this issue on launchpad. It is closed. And the resolution is to provide a clearer error message. The problem is that non-root snaps rely on the systemd --user mode. Which is missing in my case:

$ systemctl status --user
Failed to connect to bus: No medium found

And they suggest that you can bypass this like this:

sudo -i -u ubuntu snap run hello

In my case, it works:

$ sudo -i -u ubuntu snap run ruff
Ruff: An extremely fast Python linter and code formatter.
...

(Of course, I am just using Black there now.)

xealits
  • 252
  • 2
  • 13