Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cinnamon-settings : Can't update the list of extensions, applets, actions and themes #12354

Closed
pzim-devdata opened this issue Aug 15, 2024 · 7 comments
Labels

Comments

@pzim-devdata
Copy link

Distribution

Debian GNU/Linux trixie/sid

Package version

6.0.4

Graphics hardware in use

Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics]

Frequency

Always

Bug description

when I run cinnamon-settings themes or cinnamon-settings applets or cinnamon-settings actions or cinnamon-settings extensions when I click on the download/update tab nothing happen.

Steps to reproduce

neptune@Neptune:~$ cinnamon-settings themes
/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py:445: DeprecationWarning: Gtk.Window.set_wmclass is deprecated
  self.window.set_wmclass(wm_class, wm_class)
Loading Themes module
Downloading from https://cinnamon-spices.linuxmint.com/json/themes.json?time=1723705112
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/bin/Spices.py", line 842, in _ui_error_message
    markup += _("\n\nDetails:  %s") % (str(detail))
              ^
UnboundLocalError: cannot access local variable '_' where it is not associated with a value
Downloading from https://cinnamon-spices.linuxmint.com/json/themes.json?time=1723705514
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/bin/Spices.py", line 842, in _ui_error_message
    markup += _("\n\nDetails:  %s") % (str(detail))
              ^
UnboundLocalError: cannot access local variable '_' where it is not associated with a value
Downloading from https://cinnamon-spices.linuxmint.com/json/themes.json?time=1723705523
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/bin/Spices.py", line 842, in _ui_error_message
    markup += _("\n\nDetails:  %s") % (str(detail))
              ^
UnboundLocalError: cannot access local variable '_' where it is not associated with a value




neptune@Neptune:~$ cinnamon-settings applets
/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py:445: DeprecationWarning: Gtk.Window.set_wmclass is deprecated
  self.window.set_wmclass(wm_class, wm_class)
Loading Applets module
Downloading from https://cinnamon-spices.linuxmint.com/json/applets.json?time=1723706872
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/bin/Spices.py", line 842, in _ui_error_message
    markup += _("\n\nDetails:  %s") % (str(detail))
              ^
UnboundLocalError: cannot access local variable '_' where it is not associated with a value



neptune@Neptune:~$ cinnamon-settings actions
/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py:445: DeprecationWarning: Gtk.Window.set_wmclass is deprecated
  self.window.set_wmclass(wm_class, wm_class)
Loading Actions module
/usr/share/gnome/nemo/actions/ does not exist! Skipping
/usr/local/share//nemo/actions/ does not exist! Skipping
[Errno 2] Aucun fichier ou dossier de ce nom: '/usr/share//nemo/actions/__pycache__/metadata.json'
Skipping __pycache__: there was a problem trying to read metadata.json
Downloading from https://cinnamon-spices.linuxmint.com/json/actions.json?time=1723706914
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/bin/Spices.py", line 842, in _ui_error_message
    markup += _("\n\nDetails:  %s") % (str(detail))
              ^
UnboundLocalError: cannot access local variable '_' where it is not associated with a value
/usr/share/gnome/nemo/actions/ does not exist! Skipping
/usr/local/share//nemo/actions/ does not exist! Skipping
[Errno 2] Aucun fichier ou dossier de ce nom: '/usr/share//nemo/actions/__pycache__/metadata.json'
Skipping __pycache__: there was a problem trying to read metadata.json



neptune@Neptune:~$ cinnamon-settings extensions
/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py:445: DeprecationWarning: Gtk.Window.set_wmclass is deprecated
  self.window.set_wmclass(wm_class, wm_class)
Loading Extensions module
Downloading from https://cinnamon-spices.linuxmint.com/json/extensions.json?time=1723706941
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/bin/Spices.py", line 842, in _ui_error_message
    markup += _("\n\nDetails:  %s") % (str(detail))
              ^
UnboundLocalError: cannot access local variable '_' where it is not associated with a value

Expected behavior

I would like to see all available extensions, applets, actions or themes in the tab

Additional information

No response

@rcalixte
Copy link
Member

@pzim-devdata There are a few possibilities of the root cause here but it should be resolved once Cinnamon 6.2 lands in Debian's repositories. These unexpected compatibility issues are the reasons that Debian Testing/Sid are not recommended for daily use.

@pzim-devdata
Copy link
Author

Ok thank you. I will wait an update of Cinnamon

@EarldridgeJazzedPineda
Copy link

It's because the python3-requests package isn't installed.

@pzim-devdata
Copy link
Author

It's working now, thanks :-)

@leigh123linux
Copy link
Contributor

@pzim-devdata You will need to file the issue at the debian bug tracker so they can fix their packaging issue.

@Go-rom
Copy link

Go-rom commented Nov 30, 2024

Hi,

i was getting the same issue but in my case, python3-requests was installed.
I solved the issue with Synaptic by selecting all installed python3 packages on my system and reinstalling them.
Hope it might help someone in the future.

Thank you @EarldridgeJazzedPineda for your answer, it led me to the python environment issue.

@zahlman
Copy link
Contributor

zahlman commented Dec 4, 2024

This issue came up on the Linux Mint forums: https://forums.linuxmint.com/viewtopic.php?p=2556396

I tried to take a look at the relevant source code. The surrounding code appears to be this method in class Spice_Harvester:

    def _ui_error_message(self, msg, detail=None):
        dialog = Gtk.MessageDialog(transient_for=self.window,
                                   modal=True,
                                   message_type=Gtk.MessageType.ERROR,
                                   buttons=Gtk.ButtonsType.OK)
        markup = msg
        if detail is not None:
            markup += _("\n\nDetails:  %s") % (str(detail))
        esc = html.escape(markup)
        dialog.set_markup(esc)
        dialog.show_all()
        _ = dialog.run()
        dialog.destroy()

I assume (because such naming conventions are common) that the _ as in _("\n\nDetails: %s") is supposed to refer to some sort of localization function, such as with GNU gettext. I was unable to find a definition for the global _ anywhere in the file; but it's used throughout the code in other places, so I assume I've just overlooked something.

However, the code shown can't possibly be correct. The issue is that the later code _ = dialog.run() causes the name _ to be resolved at compile time as a local (reference: https://stackoverflow.com/questions/370357). This results in the error trace shown. While it may be the case that the code should display an error in OP's situation, it's supposed to display a localized error message, not crash with an uncaught exception. So there is definitely a bug here.

We can see this in the disassembly (Python 3.10 opcodes shown; YMMV):

842          40 LOAD_FAST                4 (markup)
             42 LOAD_FAST                5 (_)
             44 LOAD_CONST               3 ('\n\nDetails:  %s')
             46 CALL_FUNCTION            1
             48 LOAD_GLOBAL              7 (str)
             50 LOAD_FAST                2 (detail)
             52 CALL_FUNCTION            1
             54 BINARY_MODULO
             56 INPLACE_ADD
             58 STORE_FAST               4 (markup)

LOAD_FAST signifies that the _ name is looked up as a local, which happens because there is other code inside the function which assigns to _ without using a global declaration. Compare this for example to line 681, from the install method:

681          30 LOAD_GLOBAL              3 (_)
             32 LOAD_CONST               3 ('Installing %s')
             34 CALL_FUNCTION            1
             36 LOAD_FAST                1 (uuid)
             38 BINARY_MODULO
             40 LOAD_FAST                3 (job)
             42 LOAD_CONST               4 ('progress_text')
             44 STORE_SUBSCR

My guess is that the erroneous code is probably not meant to re-bind the _ global function - surely dialog.run() does not return a new, valid function for localizing strings. Rather, the assignment to _ was probably used at some point for debugging purposes, inadvertently breaking the (not tested at the time) detail is not None code path, and not removed.

zahlman added a commit to zahlman/cinnamon that referenced this issue Dec 4, 2024
Ref linuxmint#12354.

Assignment to `_` was almost certainly unintended in the line `_ = dialog.run()`, and has been removed.

As is, the code forced `_` to be recognized as a local (see https://stackoverflow.com/questions/370357); in the case where a non-`None` value is passed, this would mean that `_` is used before assignment.

Context implies that `_` is supposed to be a globally defined function, but further implies that the result from `dialog.run` *should not* replace that value.

Most likely, the original code was assigning to `_` for debugging purposes (i.e. so that the local value could be examined in a debugger), and the name collision was unintended.
clefebvre pushed a commit that referenced this issue Dec 5, 2024
…12554)

Ref #12354.

Assignment to `_` was almost certainly unintended in the line `_ = dialog.run()`, and has been removed.

As is, the code forced `_` to be recognized as a local (see https://stackoverflow.com/questions/370357); in the case where a non-`None` value is passed, this would mean that `_` is used before assignment.

Context implies that `_` is supposed to be a globally defined function, but further implies that the result from `dialog.run` *should not* replace that value.

Most likely, the original code was assigning to `_` for debugging purposes (i.e. so that the local value could be examined in a debugger), and the name collision was unintended.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants