tl;dr: Running unset QT_QPA_PLATFORMTHEME
fixes this.
I recently started seeing the following error on my system running test_bitcoin-qt
:
0$ src/qt/test/test_bitcoin-qt
1Unable to init server: Could not connect: Connection refused
2
3(test_bitcoin-qt:173399): Gtk-WARNING **: 21:03:26.220: cannot open display:
strace shows the failing connect:
0connect(8, {sa_family=AF_UNIX, sun_path=@"/run/user/1000/broadway1.socket"}, 34) = -1 ECONNREFUSED (Connection refused)
gdb stack trace shows:
0$ gdb -ex 'catch syscall connect' -ex run --args src/qt/test/test_bitcoin-qt
1...
2Thread 1 "b-test" hit Catchpoint 1 (call to syscall connect), 0x00007ffff6757147 in connect ()
3 from /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/libpthread.so.0
4(gdb) bt
5[#0](/bitcoin-bitcoin/0/) 0x00007ffff6757147 in connect () from /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/libpthread.so.0
6[#1](/bitcoin-bitcoin/1/) 0x00007fffe272b7c6 in wl_display_connect () from /nix/store/wzii64jykrwq9y4x7f7hnplyk9asd1an-wayland-1.19.0/lib/libwayland-client.so.0
7[#2](/bitcoin-bitcoin/2/) 0x00007fffe2f75a8a in _gdk_wayland_display_open () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgdk-3.so.0
8[#3](/bitcoin-bitcoin/3/) 0x00007fffe2f42847 in gdk_display_manager_open_display () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgdk-3.so.0
9[#4](/bitcoin-bitcoin/4/) 0x00007fffe3207ea3 in gtk_init_check () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgtk-3.so.0
10[#5](/bitcoin-bitcoin/5/) 0x00007fffe3207ed9 in gtk_init () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgtk-3.so.0
11[#6](/bitcoin-bitcoin/6/) 0x00007fffe3818fa6 in GnomeSettingsPrivate::GnomeSettingsPrivate(QObject*) () from /nix/store/m6np8hp9s198ilw8fbm3wbvdrp44jw10-qgnomeplatform-0.8.0/lib/libqgnomeplatform.so
12[#7](/bitcoin-bitcoin/7/) 0x00007fffe381a00e in GnomeSettings::palette() () from /nix/store/m6np8hp9s198ilw8fbm3wbvdrp44jw10-qgnomeplatform-0.8.0/lib/libqgnomeplatform.so
13[#8](/bitcoin-bitcoin/8/) 0x00007ffff74ffede in QApplicationPrivate::basePalette() const () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Widgets.so.5
14[#9](/bitcoin-bitcoin/9/) 0x00007ffff6e41cd0 in QGuiApplicationPrivate::setPalette(QPalette const&) () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Gui.so.5
15[#10](/bitcoin-bitcoin/10/) 0x00007ffff6e46663 in QGuiApplicationPrivate::updatePalette() () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Gui.so.5
16[#11](/bitcoin-bitcoin/11/) 0x00007ffff6e483d1 in QGuiApplicationPrivate::init() () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Gui.so.5
17[#12](/bitcoin-bitcoin/12/) 0x00007ffff7506c09 in QApplicationPrivate::init() () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Widgets.so.5
18[#13](/bitcoin-bitcoin/13/) 0x00005555556b291d in BitcoinApplication::BitcoinApplication (this=0x7fffffff0ac0) at qt/bitcoin.cpp:218
19[#14](/bitcoin-bitcoin/14/) 0x0000555555672a61 in main (argc=<optimized out>, argv=0x7fffffff0d10) at qt/test/test_main.cpp:80
Qt debug output shows:
0$ QT_DEBUG_PLUGINS=1 src/qt/test/test_bitcoin-qt
1...
2Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
3QFactoryLoader::QFactoryLoader() checking directory path "/run/mount/chainssd-2/home-work/bitcoin/src/qt/test/platformthemes" ...
4loaded library "/nix/store/m6np8hp9s198ilw8fbm3wbvdrp44jw10-qgnomeplatform-0.8.0/lib/qt-5.15.2/plugins/platformthemes/libqgnomeplatformtheme.so"
5Unable to init server: Could not connect: Connection refused
6
7(test_bitcoin-qt:173628): Gtk-WARNING **: 21:08:27.982: cannot open display:
So the failure happens loading gnome platform plugin, and apparently on my system this is enabled by an environment variable:
0$ env | grep QPA
1QT_QPA_PLATFORMTHEME=gnome
Running unset QT_QPA_PLATFORMTHEME
before the test lets it run and pass. Maybe the test itself should be unsetting this variable in test_main.cpp
, or maybe not if it is useful for QApplicationPrivate
to be respecting local system settings. I just wanted to document this problem for now in case it affects anyone else.