Unable to launch GUI using snap package

Hello,

I am unable to launch GUI using gtk-3 from service which i had created.
As per the log Error i can see is below:
–> ser[32211]: Locale not supported by C library.#012#011Using the fallback ‘C’ locale.
–> 32211]: Unable to init server: Could not connect: Connection refused
–> 2211]: cannot open display:

I have already added below in stage-packages for this GUI:
stage-packages:

  • libgtk-3-dev
  • libgtk-3-0

Just a note - GUI is an error dialog.

My actual SNAP name is “lenovo-wwan-dpr”
Any information to debug this issue will be very much helpful.
Thank you

This looks like you are not starting it in a running desktop session … or that you are missing the x11 plug in your apps entry

It looks like you aren’t using one of the desktop extensions, which not only give you the libgtk but also connects to the interfaces necessary to open dialogs. See https://snapcraft.io/docs/gnome-3-38-extension

I have already tried using extension and x11 but still getting same issue without “devmode”.
I have created test app to explain my issue below:

Below is the observation:

  1. Command -> snap install --dangerous --devmode test-gui_1.0.0-test_amd64.snap
    and then snap run test-gui
    Result is OK (able to see window )

  2. command -> snap install --dangerous test-gui_1.0.0-test_amd64.snap
    result - Fail result
    Issue is below:


Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
/snap/test-gui/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0: /snap/test-gui/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libffi.so.7: no version information available (required by /snap/test-gui/x1/usr/lib/x86_64-linux-gnu/libwayland-client.so.0)
/snap/test-gui/x1/bin/test_gui: /snap/test-gui/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libffi.so.7: no version information available (required by /snap/test-gui/x1/usr/lib/x86_64-linux-gnu/libwayland-client.so.0)
No protocol specified
Unable to init server: Could not connect: Connection refused

(test_gui:26227): Gtk-WARNING **: 11:24:36.836: cannot open display:


  1. service which i had created has “daemon: oneshot” . It gives same error as above 2)

Any information regarding this will be helpful.
Thank you !!

on my ubuntu desktop it runs up to a dbus error (which is expected since you did not declare the dbus plug) …

asking that again, do you run it properly in a desktop session ?

Sorry to ask may i know how to check “desktop session” ?
I am using ubuntu 20.04.1 LTS version

well, are you starting your app from within a graphical terminal on a desktop or are you trying to launch it from a tty without any graphical environment … the test app above, laubnched manually from a graphical terminal definitely goes beyond the “cannot open display:” error (which translates to “i can not connect to a running graphical session”) if i build and run it here

Thank you for your reply.
yes , i am running in graphical terminal. If i install using “–devmode” then i can see pop-up window after performing “snap run gtk-gui” . but , it goes “can not open display error” when i install without “–devmode”

after adding the dbus slot to your test-gui tree it starts fine for me …

Thank you for your reply.
Can you please share “snap connect test-gui:xxx test-gui:dbus-svc” command which you had used to connect this slot ?

i did not connect anything:

$ snap connections test-gui|grep dbus
dbus                      -                         test-gui:dbus-svc                -

just adding the slot to the app is enough to allow it to talk to the session bus (if you’d upload this to the store the upload would go into manual review, but it has not effects when using the snap locally)

either way, this was just solving the issue i had here with your test app … it is still not clear why you get the “cannot open display” error when doing the same …

Ok … I can see same result using command “snap connections test-gui|grep dbus” .
So , in my environment installing snap with “–devmode” , its working but not without it.
Again getting "cannot open display” when i install without devmode.
Not sure why its happening .