Why yum update fails with "Plugins can't be imported" in Red Hat Enterprise Linux 5 ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.7 and onwards
  • Red Hat Subscription Management (RHSM)

Issue

  • yum update fails with the following error :-
# yum update
Plugin "product-id" can't be imported
Plugin "subscription-manager" can't be imported
Unable to find Subscription Manager module.
Error: cannot import name init_dep_injection

Resolution

  • Install missing m2crypto package on system and upgraded yum-rhn-plugin package on affected system.
  • Re install yum and subscription-manager package.
  • Remove all the duplicate packages (if present) as mentioned in the Diagnostic Steps.

Root Cause

  • Red Hat supplied m2crypto package missing on system which caused this error.
  • Presense of duplicate packages on the system.
  • Subscription manager-related files are modified.

Diagnostic Steps

  • Collect following details from affected system:
$ strace -fxvto /tmp/strace.out yum update
  • Check whether there are any files listed as modified or missing in the output of the following command:
# rpm -V yum subscription-manager
  • If so, then download the yum and subscription-manager packages from RHN and reinstall them manually :
# rpm --replacepkgs -vh yum-x.x.x.y.y.noarch.rpm subscription-manager-x.x.yy-x.x.x.rpm
  • Run the following command to scan the rpm database for any other duplicates as well:
# package-cleanup --dupes
  • If the output looks correct, then remove the old versions of these duplicates with:
# package-cleanup --cleandupes

Make sure that subscription-manager and subscription-manager-rhsm are of the same version:

subscription-manager-rhsm-1.20.10-7.el6.x86_64
subscription-manager-1.20.10-7.el6.x86_64

If they are not, it might be a cause for plugins unable to be imported:

subscription-manager-1.16.8-8.el6.x86_64
subscription-manager-rhsm-1.20.10-7.el6.x86_64
  • Component
  • yum

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

3 Comments

cxvra00a0016:/home/a256447> rpm -qa | grep yum
yum-metadata-parser-1.1.2-4.el5
yum-3.2.22-40.el5
yum-security-1.1.16-21.el5
yum-kmod-1.1.16-21.el5
yum-rhn-plugin-0.5.4-29.el5
yum-updatesd-0.9-6.el5_10
cxvra00a0016:/home/a256447> rpm -qa | grep m2crypto
m2crypto-0.16-9.el5
cxvra00a0016:/home/a256447> rpm -qa | grep subscription
subscription-manager-1.8.22-1.el5

I have downloaded and installed the subscription manager, but registration still fails.
In the previous comment I have the versions of the YUM products. Are those correct and in sync?

Here is the output from the strace command:

cxvra00a0016:/home/a256447> strace -fxvto /tmp/strace.out yum update
Plugin "product-id" can't be imported
Plugin "rhnplugin" can't be imported
Plugin "subscription-manager" can't be imported
Loaded plugins: kmod, security
Setting up Update Process
No Packages marked for Update
cxvra00a0016:/home/a256447>

•Red Hat Enterprise Linux 5.7 and onwards - really? I guess 7.5 onwards