Gnome cannot start from systemd vnc: TypeError: this._userProxy.Display is null in getCurrentSessionProxy@resource:///org/gnome/shell/misc/loginManager.js
Ubuntu 20.04 Gnome shell 3.36.3 Tigervnc 1.10.1
There seems to be a problem that people have been stumbling into now for many years with no resolution, and if you google it, you'll find frustrated people in far flung forums, mailing lists and support groups, namely that if you start a vnc session from systemd, Gnome won't start properly. Note that you can start a regular X session fine... you can start xterms and window managers etc, and from what I hear, you can start KDE fine as well.. but no so for Gnome. And you can start the vnc session from the command line and gnome starts fine. It's just when it comes from systemd it doesn't work. Based on my investigation, the most likely location of the issue is in Gnome, and most likely in gnome-shell.
Steps to reproduce
- Install a vnc server. (I'm using Tiger VNC but I've seen people with other VNCs with the same issue)
- set up a systemd specification in /etc/systemd/system/vncserver@.service (will give example below)
- set up an instance of it (aka cd /etc/systemd/system ; ln -s vncserver@.service firstname.lastname@example.org
- start it up: sudo systemctl start vncserver@1
- Connect to localhost:1 with a vnc client (Tiger VNC viewer is a good choice)
What you'll see is an Xsession without gnome. If you started other X programs, like an xterm, you'll see that, if not, you'll probably see a plain grey screen.
What did GNOME Shell do that was unexpected?
If you do a
systemctl status email@example.com
What you will see is:
Aug 03 23:50:44 ThinkPad gnome-shell: Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly. Aug 03 23:50:44 ThinkPad gnome-shell: JS ERROR: TypeError: this._userProxy.Display is null getCurrentSessionProxy@resource:///org/gnome/shell/misc/loginManager.js:114:41 ScreenShield@resource:///org/gnome/shell/ui/screenShield.js:105:28 _initializeUI@resource:///org/gnome/shell/ui/main.js:200:24 start@resource:///org/gnome/shell/ui/main.js:146:5 @<main>:1:47 Aug 03 23:50:44 ThinkPad gnome-shell: Execution of main.js threw exception: Script <main> threw an exception Aug 03 23:50:44 ThinkPad gnome-session: gnome-session-binary: WARNING: App 'org.gnome.Shell.desktop' exited with code 1 Aug 03 23:50:44 ThinkPad gnome-session: gnome-session-binary: WARNING: App 'org.gnome.Shell.desktop' respawning too quickly
From having a bit of a look around, this looks to be related to code in gnome-shell
What did you expect to happen
I expect to see a Gnome workspace, not a raw Xsession. Note that if I start a vncserver from a logged in command line, it works fine:
tigervncserver -localhost no :1
Relevant logs, screenshots, screencasts etc.
This is what I have in /etc/systemd/system/vncserver@.service
[Unit] Description=Start TigerVNC server at startup After=syslog.target network.target [Service] Type=simple User=chris #PAMName=login Group=chris WorkingDirectory=/home/chris PIDFile=/home/chris/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/tigervncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/tigervncserver -depth 24 -geometry 1280x800 -localhost no :%i ExecStop=/usr/bin/tigervncserver -kill :%i [Install] WantedBy=multi-user.target
Note that the PAMName I have commented out, that was something I was experimenting with to see if it would help at all, but to no avail.
This is what I have in my xstartup:
#!/bin/bash PATH=/usr/bin:/bin:$PATH #unset SESSION_MANAGER #unset DBUS_SESSION_BUS_ADDRESS test -r $HOME/.Xresources && xrdb $HOME/.Xresources vncconfig -iconic & dbus-launch --exit-with-session gnome-session & #exec /etc/X11/xinit/xinitrc #gnome-session & xterm
I tried various combinations of unsetting variables, starting different things. Basically X programs can start fine, I can start fvwm and xterm with no problem, but Gnome crashes.
Other things I tried was starting tigervncserver in the service with the runuser command.