7

I am getting error when installing updates or patches in RHEL-7.7.3..

error: Failed to initialize NSS library

There was a problem importing one of the Python modules

required to run yum. The error leading to this problem was:

 

   cannot import name ts

 

Please install a package which provides this module, or

verify that the module is installed correctly.

 

It's possible that the above module doesn't match the

current version of Python, which is:

2.7.5 (default, Aug  2 2016, 04:20:16)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

 

If you cannot solve this problem yourself, please go to

the yum faq at:

  http://yum.baseurl.org/wiki/Faq

HOW can I resolve it?

5

This could be related to a bug that surfaced yesterday with installing glibc.686 on a new install of RHEL 7.3, which causes both yum and rpm to break. See this Red Hat solutions post. Unfortunately I do not have a solution at the moment on how to fix it after you install glibc.686, however the solution on that page for 7.3 is to install nspr along side of it. You could reinstall RHEL 7.3 or restore from a backup and then run:

yum install glibc.i686 nspr

This supposedly bypasses the issue.

Edit: I was able to get this working on a broken instance of RHEL 7.3 by manually downloading an nspr library and running the following command:

LD_PRELOAD=./libnspr4.so yum update nspr

This will fix your yum and rpm. Good luck.

1
  • 2
    I got the .so but even this gives me error: Failed to initialize NSS library. No matter how I attempt to invoke dnf, yum, rpm, or rpm2cpio it always errors out with that message.
    – metaleap
    Oct 28 '17 at 19:36
8

If you're like me, trying to save a server buckled under as-usual-unnecessary package-management force, from a rescue/chroot environment,

— be sure to bind-mount a valid /dev filesystem inside the chroot.

For, as strace -f rpm --help shows, it needs a /dev/urandom.


Enlightenment props go to this GitHub issue which highlighted the /dev/urandom thing which I definitely seen near ENOENT in strace log, but somehow didn't pay attention to. I've bind-mounted /{proc,sys} as well, for good measure. The issue went away; server rescued, yay!

2
  • 2
    This is the correct answer, at least today. Rpm needs some nss libs, and their initialization needs /dev/urandom, probably for some security thing. That is all.
    – peterh
    Mar 25 '19 at 14:28
  • if you're in a chroot /dev is not the only needed path to bind-mount. you'll need /proc /sys /dev/pts see arch linux wiki Jan 5 at 23:37
4

The answer which worked for me:

download nspr package from nspr-4.13.1-1.0.el7_3.x86_64.rpm

rpm2cpio nspr-4.13.1-1.0.el7_3.x86_64.rpm | cpio -idmv

LD_PRELOAD=./usr/lib64/libnspr4.so yum update nspr (directory may differ, but should mostly be good)

Problem solved. Thanks for those who gave the clue.

Christian COMMARMOND

1

@Christian everything works but you need a fresh download link http://rpm.pbone.net/index.php3/stat/4/idpl/36086786/dir/scientific_linux_7/com/nspr-4.13.1-1.0.el7_3.x86_64.rpm.html

0

We're getting this too. After reinstalling the VM we tried nspr alongside glibc.i686 and it appeared to fix the problem, as did installing nspr first, but on the next server it's not working.

The issue (for us) appears to actually be a dependency - nss-softokn-freebl.* The .x86_64 version doesn't match the .i686 version, so it's trying to update them both and the latest is triggering the problem.

Still working through it. Hope this helps someone.

-2

Here is the link to the fix - https://access.redhat.com/solutions/3134931 Hope it helps.

2
  • Links rot. Please be so kind to summarize (using words) the article that you link to.
    – ulidtko
    Dec 26 '18 at 15:12
  • It also requires a Red Hat subscription to read this content. Jan 6 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.