Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
When the display is unset, importing Gtk in Python gives error message. The display is unset by default when ssh:ing to a machine.
Our use case is that want to check if Gtk is available without actually using it. Once we confirm that it is available we can start using it, or take another route if it is unavailable.
How reproducible:
Always shows, given that the display is unset.
Steps to Reproduce:
Actual results:
Import Gtk in Python:
[cendio@lab-243 ~]$ DISPLAY= python3
Python 3.6.8 (default, Sep 9 2021, 07:49:02)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.require_version("Gtk", "3.0")
>>> from gi.repository import Gtk
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Expected results:
Importing Gtk should not give error messages.
Additional info:
Aside from the error message, everything seem to be working as expected. The errors are not Gtk errors, so it is unclear how they can be silenced.
Additionally, this error message is not seen when importing Gtk in Python on RHEL 7.9 or RHEL 9.0.
As you say, this is not a GTK error message, so there is not really a GTK issue here that could be addressed in this bug.
If you want to handle the situation, you can wrap the import statement in a try: except: block, like this
import gi
try:
from gi.repository import Gtk
except ImportError:
print("no display available")
The error message will still happen, unfortunately.
The cause of the error message seems to be file libgdk-3.so.0, so I would argue that it indeed is a GTK issue.
Further, this error message is only seen on RHEL 8, which uses GTK 3.22. When checking that version, the only hit I get is in gdkdisplay-broadway.c, which seems odd as we are not trying to use broadway.
https://github.com/GNOME/gtk/blob/3.22.30/gdk/broadway/gdkdisplay-broadway.c#L112
Description of problem: When the display is unset, importing Gtk in Python gives error message. The display is unset by default when ssh:ing to a machine. Our use case is that want to check if Gtk is available without actually using it. Once we confirm that it is available we can start using it, or take another route if it is unavailable. How reproducible: Always shows, given that the display is unset. Steps to Reproduce: Actual results: Import Gtk in Python: [cendio@lab-243 ~]$ DISPLAY= python3 Python 3.6.8 (default, Sep 9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>> gi.require_version("Gtk", "3.0") >>> from gi.repository import Gtk Unable to init server: Could not connect: Connection refused Unable to init server: Could not connect: Connection refused Expected results: Importing Gtk should not give error messages. Additional info: Aside from the error message, everything seem to be working as expected. The errors are not Gtk errors, so it is unclear how they can be silenced. Additionally, this error message is not seen when importing Gtk in Python on RHEL 7.9 or RHEL 9.0.