gnome-terminal fails to start (timed out)

I just upgraded from Ubuntu 16.04 to 18.04. My workflow is to connect from Windows using VcXsrv to Ubuntu (ssh with X tunneling), starting a xterm on Ubuntu. Inside the xterm I am typing gnome-terminal to get a gnome-terminal.

Since the upgrade this is not working anymore. I am getting

$ gnome-terminal  
# Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.  
# Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Fehler beim Aufruf von StartServiceByName für org.gnome.Terminal: Zeitüberschreitung wurde erreicht  

or when starting with English locale

$ LANG=en_US.utf8 gnome-terminal  
# Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.  
# Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: Timeout was reached

I am not always getting the first line, but I am always gettint the timeout error.

Digging more into the issue I found out

  • sudo gnome-terminal works
  • gnome-terminal works when run in a xterm when locally logged in on the PC
  • when I am also logged in locally on the PC then gnome-terminal in the remote session's xterm opens a gnome-terminal on the local session on the PC (still getting the first error line about registering with accessibility bus)
  • when I am also logged in over rdp (Windows network connection) then a gnome-terminal in the ssh session opens a gnome-terminal in the xrdp session
  • when I login over rdp (Windows network connection), logoff there, then gnome-terminal can open a gnome-terminal

What can I do to get gnome-terminal in a remote session's xterm to work?


Solution 1:

Identical issue, found the solution.

Running 'tail -f /var/log/syslog' in a 2nd terminal when testing in the first terminal gives the following when I launch gnome-terminal after 'sudo bash':

Mar 23 10:11:59 X399-DESIGNARE-EX dbus-daemon[2584]: [session uid=0 pid=2582] Activating service name='org.gnome.Terminal' requested by ':1.6' (uid=0 pid=2929 comm="/usr/bin/gnome-terminal.real " label="unconfined")
Mar 23 10:11:59 X399-DESIGNARE-EX gnome-terminal-[2934]: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-GAXcx1c8OL: Connection refused
Mar 23 10:11:59 X399-DESIGNARE-EX dbus-daemon[2584]: [session uid=0 pid=2582] Successfully activated service 'org.gnome.Terminal'
Mar 23 10:11:59 X399-DESIGNARE-EX gnome-terminal-[2934]: The owner of /home/<user>/.config/ibus/bus is not root!

I get the following when running gnome-terminal as myself:

Mar 23 10:16:30 X399-DESIGNARE-EX dbus-daemon[2564]: [session uid=1000 pid=2564] Activating via systemd: service name='org.gnome.Terminal' unit='gnome-terminal-server.service' requested by ':1.4' (uid=1000 pid=2959 comm="/usr/bin/gnome-terminal.real " label="unconfined")
Mar 23 10:16:30 X399-DESIGNARE-EX systemd[2435]: Starting GNOME Terminal Server...
Mar 23 10:16:30 X399-DESIGNARE-EX systemd[2435]: gnome-terminal-server.service: Main process exited, code=exited, status=10/n/a
Mar 23 10:16:30 X399-DESIGNARE-EX gnome-terminal-server[2962]: Unable to init server: Could not connect: Connection refused
Mar 23 10:16:30 X399-DESIGNARE-EX gnome-terminal-server[2962]: Failed to parse arguments: Cannot open display:
Mar 23 10:16:30 X399-DESIGNARE-EX systemd[2435]: gnome-terminal-server.service: Failed with result 'exit-code'.
Mar 23 10:16:30 X399-DESIGNARE-EX systemd[2435]: Failed to start GNOME Terminal Server.

...after a lot of digging I finally found gnome-terminal not starting, which indicated there is an issue with dbus not refreshing its environment when services get requested from non-root. The following steps work around the problem:

  1. Create a script in your home folder, e.g.:

vim ~/term

  1. Add the following to the script and save it:

#!/usr/bin/env bash dbus-update-activation-environment --systemd --all gnome-terminal &

  1. Make script executable

chmod 755 ~/term

  1. Run '~/term' to start up gnome-terminal as user (not root) and it should start correctly.

NOTE TO MODERATOR:

Please do NOT delete an answer that provides additional detail for the problem. What you deleted was not any violation of the posting guidelines, and provided substantial additional information for anyone trying to track down the solution. This answer does not provide that additional information and I am disinclined to go through the effort of recovering it.

This answer solves the problem.

PLEASE DO NOT DELETE IT!