projecthamster / hamster

GNOME time tracker
http://projecthamster.org
GNU General Public License v3.0
1.08k stars 249 forks source link

App startup fails #714

Closed clobrano closed 1 year ago

clobrano commented 1 year ago

On Fedora 36, using wayland, launching Hamster from the Application list (or Dock, once pinned), does not work.

journalctl log shows this error

g_app_launch_context_launch_failed: assertion 'startup_notify_id != NULL' failed

Hamster installed via Flatpak, v3.0.2

clobrano commented 1 year ago

It seemed different that #713, so I opened a new bug, feel free to close it if is the same problem.

clobrano commented 1 year ago

I just notice that it crashes only on Gnome (in Fedora 36), while un KDE it works just fine. Let me know if I can help with more info

EDIT: I will take this back. Today I got the same error on KDE too. Yesterday worked fine because I lunched it from Discover :shrug:

fgrosse commented 1 year ago

I have the same issue on Fedora 37, using wayland and Gnome. When I try to start the hamster GUI nothing happens and I see the following in the logs:

Mär 21 08:12:27 argo python3[15744]: detected unhandled Python exception in '/usr/bin/hamster'
Mär 21 08:12:27 argo hamster[15744]: Traceback (most recent call last):
Mär 21 08:12:27 argo hamster[15744]:   File "/usr/bin/hamster", line 415, in <module>
Mär 21 08:12:27 argo hamster[15744]:     i18n.setup_i18n()
Mär 21 08:12:27 argo hamster[15744]:   File "/usr/lib/python3.11/site-packages/hamster/lib/i18n.py", line 24, in setup_i18n
Mär 21 08:12:27 argo hamster[15744]:     module.bind_textdomain_codeset('hamster','utf8')
Mär 21 08:12:27 argo hamster[15744]:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mär 21 08:12:27 argo hamster[15744]: AttributeError: module 'gettext' has no attribute 'bind_textdomain_codeset'
Mär 21 08:12:27 argo abrt-server[15751]: Executable '/usr/bin/hamster' doesn't belong to any package and ProcessUnpackaged is set to 'no'
Mär 21 08:12:27 argo abrt-server[15751]: 'post-create' on '/var/spool/abrt/Python3-2023-03-21-08:12:27-15744' exited with 1
Mär 21 08:12:27 argo abrt-server[15751]: Deleting problem directory '/var/spool/abrt/Python3-2023-03-21-08:12:27-15744'
Mär 21 08:12:27 argo systemd[3633]: dbus-:1.2-org.gnome.Hamster.GUI@1.service: Main process exited, code=exited, status=1/FAILURE
Mär 21 08:12:27 argo systemd[3633]: dbus-:1.2-org.gnome.Hamster.GUI@1.service: Failed with result 'exit-code'.
Mär 21 08:12:27 argo gnome-shell[3790]: g_app_launch_context_launch_failed: assertion 'startup_notify_id != NULL' failed

I installed hamster from source using the master branch at 71076a579419ceaba2fed9b4bebcd1cf7f408d10.

fgrosse commented 1 year ago

A simple way to reproduce the issue is by executing hamster (or hamster-service) directly on the CLI:

$ hamster        
Traceback (most recent call last):
  File "/usr/bin/hamster", line 415, in <module>
    i18n.setup_i18n()
  File "/usr/lib/python3.11/site-packages/hamster/lib/i18n.py", line 24, in setup_i18n
    module.bind_textdomain_codeset('hamster','utf8')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'gettext' has no attribute 'bind_textdomain_codeset'

Even though I'm no Python expert, I suspect this to be a Python 3.11 issue. I found the following line in the Python 3.11 changelog:

Removed the deprecated gettext functions lgettext(), ldgettext(), lngettext() and ldngettext(). Also removed the bind_textdomain_codeset() function, the NullTranslations.output_charset() and NullTranslations.set_output_charset() methods, and the codeset parameter of translation() and install(), since they are only used for the l*gettext() functions. (Contributed by Dong-hee Na and Serhiy Storchaka in bpo-44235.)

When I remove the offending bind_textdomain_codeset function call and reinstall hamster it seems to work as expected :tada: .

diff --git a/src/hamster/lib/i18n.py b/src/hamster/lib/i18n.py
index 7bb89773..08488862 100644
--- a/src/hamster/lib/i18n.py
+++ b/src/hamster/lib/i18n.py
@@ -21,8 +21,6 @@ def setup_i18n():
             module.bindtextdomain('hamster', locale_dir)
             module.textdomain('hamster')

-            module.bind_textdomain_codeset('hamster','utf8')
-
         gettext.install("hamster", locale_dir)

     else:
clobrano commented 1 year ago

The above is surely necessary, however installing from source (master HEAD) does not incurr into this issue anyway