2

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
  • 45
  • See if my post at https://askubuntu.com/questions/1492329/how-to-get-snap-applications-to-run-on-a-vnc-session works for you. – Steve Pringle Nov 11 '23 at 13:44
  • Apologies for the late response @StevePringle I just tried your modified startup script, but unfortunately it didn't work for me: I got a grey screen saying something like "Something went wrong, disabled/disconnected everything for safety". I'm afraid I just don't understand enough of what's in this script to get it to work properly for me, so I'll need to educate myself first. – Sita Feb 20 '24 at 09:09

2 Answers2

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
  • 45
Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212
  • Thanks, I think I'll do that. In fact, I'm thinking of moving away from Snaps entirely, perhaps try again in a few years – Sita Feb 27 '23 at 06:55
0

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
  • 101