Bug 1571081 - dnf update fail with error "TypeError: could not get a reference to type class"
Summary: dnf update fail with error "TypeError: could not get a reference to type class"
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: libmodulemd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Stephen Gallagher
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-24 05:28 UTC by Dave Young
Modified: 2018-10-03 14:20 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-26 01:15:08 UTC
Type: Bug


Attachments (Terms of Use)

Description Dave Young 2018-04-24 05:28:00 UTC
Description of problem:

Hi,

I'm not sure if I missed some pkgs update, but my rawhide now can not install pkgs anymore with below error:

[root@* linux]# dnf update
Last metadata expiration check: 0:00:00 ago on Tue 24 Apr 2018 01:24:26 PM CST.
/usr/lib/python3.6/site-packages/dnf/base.py:220: Warning: cannot retrieve class for invalid (unclassed) type 'void'
  module_defaults_prioritizer = Modulemd.Prioritizer()

Traceback (most recent call last):
  File "/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 115, in cli_run
    cli.run()
  File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1015, in run
    self._process_demands()
  File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 768, in _process_demands
    load_available_repos=self.demands.available_repos)
  File "/usr/lib/python3.6/site-packages/dnf/base.py", line 500, in fill_sack
    self._setup_modules()
  File "/usr/lib/python3.6/site-packages/dnf/base.py", line 220, in _setup_modules
    module_defaults_prioritizer = Modulemd.Prioritizer()
TypeError: could not get a reference to type class

The dnf related rpm installed as following:
rpm -qa|grep dnf
python3-dnf-2.7.5-12.fc29.noarch
dnf-conf-2.7.5-12.fc29.noarch
python2-dnf-2.7.5-12.fc29.noarch
dnf-plugins-core-2.1.5-4.fc28.noarch
python3-dnf-plugins-core-2.1.5-4.fc28.noarch
dnf-automatic-2.7.5-12.fc29.noarch
dnf-2.7.5-12.fc29.noarch
libdnf-0.11.1-3.fc28.x86_64
dnf-yum-2.7.5-12.fc29.noarch

Any help are appreciated.

Thanks!

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Martin Hatina 2018-04-24 06:19:45 UTC
Hi, can you run following command and provide the output?

rpm -q libmodulemd

Thank you.

Comment 2 Dave Young 2018-04-24 08:34:02 UTC
Hi,

It is: libmodulemd-1.3.0-2.fc29.x86_64

Comment 3 Martin Hatina 2018-04-24 08:38:19 UTC
Version of libmodulemd is correct, reassigning to libmodulemd.

Comment 4 Stephen Gallagher 2018-04-24 10:05:34 UTC
Can you please run `rpm -q python3-gobject-base`?

Libmodulemd here is not doing anything except calling a GObject constructor so I wonder if something broke in the Python binding. I’ll try to reproduce in a Rawhide VM as well.

Comment 5 Stephen Gallagher 2018-04-24 12:17:13 UTC
I can't reproduce this. I tried to do so with both a VM and a docker container on Rawhide and it's just not happening for me.

Comment 6 Dave Young 2018-04-25 01:42:03 UTC
(In reply to Stephen Gallagher from comment #4)
> Can you please run `rpm -q python3-gobject-base`?
> 
> Libmodulemd here is not doing anything except calling a GObject constructor
> so I wonder if something broke in the Python binding. I’ll try to reproduce
> in a Rawhide VM as well.

python3-gobject-base-3.26.1-1.fc28.x86_64, tried update python3-gobject downloaded rpms, but dnf still does not work.

$ rpm -Uvh python3-gobject-*
warning: python3-gobject-3.28.2-1.fc29.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 429476b4: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:python3-gobject-base-3.28.2-1.fc2################################# [ 25%]
   2:python3-gobject-3.28.2-1.fc29    ################################# [ 50%]
Cleaning up / removing...
   3:python3-gobject-3.26.1-1.fc28    ################################# [ 75%]
   4:python3-gobject-base-3.26.1-1.fc2################################# [100%]
[root@dhcp-128-65 Downloads]# dnf search python3
Last metadata expiration check: 20:16:09 ago on Tue 24 Apr 2018 01:24:26 PM CST.
/usr/lib/python3.6/site-packages/dnf/base.py:220: Warning: cannot retrieve class for invalid (unclassed) type 'void'
  module_defaults_prioritizer = Modulemd.Prioritizer()

Traceback (most recent call last):
  File "/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 115, in cli_run
    cli.run()
  File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1015, in run
    self._process_demands()
  File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 768, in _process_demands
    load_available_repos=self.demands.available_repos)
  File "/usr/lib/python3.6/site-packages/dnf/base.py", line 500, in fill_sack
    self._setup_modules()
  File "/usr/lib/python3.6/site-packages/dnf/base.py", line 220, in _setup_modules
    module_defaults_prioritizer = Modulemd.Prioritizer()
TypeError: could not get a reference to type class

Comment 7 Dave Young 2018-04-25 02:01:15 UTC
I'm using a workaround below to comment out the module stuff, with the workaround dnf update works, let's see if I can fix it after a whole system update.

--- base.py     2018-04-25 09:59:35.657731593 +0800
+++ base.py.new 2018-04-25 09:59:02.891753301 +0800
@@ -217,9 +217,9 @@
                 self.sack.add_excludes(query)

     def _setup_modules(self):
-        module_defaults_prioritizer = Modulemd.Prioritizer()
+        #module_defaults_prioritizer = Modulemd.Prioritizer()
         # HACK: https://github.com/fedora-modularity/libmodulemd/issues/42
-        module_defaults_prioritizer.add([], 0)
+        #module_defaults_prioritizer.add([], 0)

         # read defaults from repos
         for repo in self.repos.iter_enabled():
@@ -259,11 +259,11 @@
                 raise

         # resolve defaults and store them for future use
-        for default in module_defaults_prioritizer.resolve():
-            try:
-                self.repo_module_dict[default.peek_module_name()].defaults = default
-            except KeyError:
-                logger.debug("No module named {}, skipping.".format(default.peek_module_name()))
+        #for default in module_defaults_prioritizer.resolve():
+        #    try:
+        #        self.repo_module_dict[default.peek_module_name()].defaults = default
+        #    except KeyError:
+        #        logger.debug("No module named {}, skipping.".format(default.peek_module_name()))

         self.repo_module_dict.read_all_module_confs()
         self._module_persistor = ModulePersistor()

Comment 8 Stephen Gallagher 2018-04-25 14:21:45 UTC
I really want to try and figure out under what circumstances this happens. It's definitely a bug somewhere in the python binding layer. I wish I could reproduce it, but I've tried pretty much everything I can think of.

Comment 9 Dave Young 2018-04-26 01:15:08 UTC
It could be some dependency issue,  after a `dnf update`, I added back the commented code, it works now.

But since I can not reproduce as well after a rawhide system wide update, I will close this bug.  Will reopen when I see it again.

Thanks!

Comment 10 Michael Young 2018-04-27 21:05:31 UTC
(In reply to Stephen Gallagher from comment #8)
> I really want to try and figure out under what circumstances this happens.
> It's definitely a bug somewhere in the python binding layer. I wish I could
> reproduce it, but I've tried pretty much everything I can think of.

I saw this as well trying to update F27 to F28 on a computer with limited free space - updating the fedora release and repo packages and then ran dnf update dnf after which I then saw this issue. I updated a few likely dnf related packages, then found this bug and updated python3-gobject-base and python3-gobject which didn't solve the problem. However my next update of gobject-introspection (and the dependent glib2 packages) did fix it and dnf worked again.

Comment 11 James Szinger 2018-05-01 01:05:20 UTC
I also encounterd this bug during a partial upgrade from F27 to 28.  The sequence of commands from a full updated F27 was

# dnf --releasever=28 update fedora-release
# dnf update \*dnf\* rpm

dnf is now broken.  I then applied the workarouond in comment 7 above (https://bugzilla.redhat.com/show_bug.cgi?id=1571081#c7), and updated gobject-introspection.

dnf update gobject-introspection.x86_64

I then reverted the workaround and dnf works.

There is definitely a broken dependency version somewhere between dnf and gobject-introspection.  I think there is enough here to reproduce, although this is not a supported upgrade path.  

The dependency chain looks like

dnf -> python3-dnf = 2.7.5-12.fc28 -> python3-gobject-base -> gobject-introspection(x86-64) >= 1.46.0

I still have python3-gobject-base-3.26.1-1.fc27.x86_64

Perhaps there's an ABI-breaking update from gobject-introspection-1.54.1-1.fc27.x86_64 to gobject-introspection-1.56.1-1.fc28.x86_64, even though both provide libgirepository-1.0.so.1()(64bit)?

Comment 12 Sammy 2018-05-01 16:03:01 UTC
Just encountered the same bug doing dnf update from F27 to F28. Above procedure worked as well but it is too complicated for most people.

Comment 13 I. Grudev 2018-09-30 13:35:44 UTC
I've got the issue after my system froze and had to reboot while dnf was still updating.

Comment 14 William H. Haller 2018-10-03 14:20:50 UTC
Also just saw this on an upgrade of a virtual server from F27 to F28. To consolidate the comments above to what worked here, download

glib2, gobject-introspection, python3-gobject-base, and python3-gobject

and upgrade via rpm -Uvh.

dnf then works without the code changes to base.py


Note You need to log in before you can comment on or make changes to this bug.