Dnf upgrade failing - libstdc+++ installed in two different versions

I try to do a “dnf upgrade”, but it fails with:

Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction check error:
  file /usr/share/gcc-9/python/libstdcxx/__pycache__/__init__.cpython-37.opt-1.pyc from install of libstdc++-9.1.1-1.fc30.i686 conflicts with file from package libstdc++-9.0.1-0.10.fc30.x86_64
  file /usr/share/gcc-9/python/libstdcxx/__pycache__/__init__.cpython-37.pyc from install of libstdc++-9.1.1-1.fc30.i686 conflicts with file from package libstdc++-9.0.1-0.10.fc30.x86_64

Error Summary

Any idea how to get rid of this? If I try to remove the package, it says:

Error: 
 Problem: The operation would result in removing the following protected packages: dnf

Help please!

sudo rpm --rebuilddb
sudo dnf clean all
sudo dnf remove --duplicates
sudo dnf autoremove
sudo dnf check all
sudo dnf --refresh upgrade

Ensure the back-end DB integrity, clean caches, metadata, etc., complete unfinished transactions, clean up leftovers, check the consistency via the front-end, perform the upgrade if the issues are resolved.

@vgaetera—please explain the error and the diagnostic process that brings you to those commands as a solution. Simply giving commands is not encouraged. We also want the users to understand what is happening and how they’re going about fixing it. :slightly_smiling_face:

@linutux: the error is because you have both i686 and x86_64 builds of libstdc++ which is fine, but somehow they’re of different versions. Could you please try:

sudo dnf clean all
sudo dnf update libstdc++ 

That should hopefully update both packages and bring them back in sync. If it doesn’t, you can try to remove the i686 package first, update your system, and reinstall it if you need it. Please check the transaction list before proceeding here, though. dnf may try to remove other tools that depend on the library:

sudo dnf remove libstdc++.i686
sudo dnf update --refresh
sudo dnf install libstdc++.i686