My system is centos7.

[root@centos7 caiyiheng]# uname -a
Linux centos7 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 
x86_64 x86_64 x86_64 GNU/Linux

My system run in a virtualbox.

When I run the cmd yum -y update, and press ctrl+c while yum is updateing something. after that I found I can't use yum or rpm anymore. when I input yum or rpm it show as:

[root@centos7 caiyiheng]# yum
error: Failed to initialize NSS library
error: no dbpath has been set
error: cannot open Packages database in /%{_dbpath}

Error: rpmdb open failed
[root@centos7 caiyiheng]# rpm
error: Failed to initialize NSS library

most yum or rpm command can't work, such as yum install,yum clean all even yum --help.

I check /var/log/yum.log, it show as:

[root@centos7 caiyiheng]# tail -f /var/log/yum.log
Sep 21 05:53:21 Installed: wget-1.14-15.el7_4.1.x86_64
Sep 21 05:53:21 Installed: lsof-4.87-5.el7.x86_64
Sep 21 05:53:22 Installed: net-tools-2.0-0.22.20131004git.el7.x86_64
Sep 26 17:28:11 Updated: libgcc-4.8.5-28.el7_5.1.x86_64
Sep 26 17:28:12 Installed: 1:grub2-common-2.02-0.65.el7.centos.2.noarch
Sep 26 17:28:13 Installed: 1:grub2-pc-modules-2.02-0.65.el7.centos.2.noarch
Sep 26 17:28:13 Installed: firewalld-filesystem-
Sep 26 17:28:14 Updated: tzdata-2018e-3.el7.noarch
Sep 26 17:28:14 Updated: ncurses-base-5.9-14.20130511.el7_4.noarch
Sep 26 17:28:15 Updated: nss-softokn-freebl-3.36.0-5.el7_5.x86_64

and I search in google for a whole day, found lots of solutions may like my problem, I tried them but nothing happen.

such as

I even download the rpm https://centos.pkgs.org/7/centos-updates-x86_64/nss-softokn-freebl-3.36.0-5.el7_5.x86_64.rpm.html

and rpm2cpio nss-softokn-freebl-3.36.0-5.el7_5.x86_64.rpm | cpio -idmv and copy ./usr/lib or lib64 or ./etc to /usr/lib /usr/lib64 /etc, but all of that can't solve my problem.

Someone mentioned that yum has a problem with chroot (https://bugs.centos.org/view.php?id=14767) but it doesn't match my situation, I even tried that, but nothing happen.

migrated from stackoverflow.com Sep 28 '18 at 7:00

This question came from our site for professional and enthusiast programmers.

  • Can you check rpm -qa |grep nss and edit your question to post the results please (if it will let you run that) – user3788685 Sep 27 '18 at 17:50
  • no, can't run rpm -qa,show the same error,maybe I need to reinstall my system. – rangercyh Sep 28 '18 at 6:11
  • Have you tried running that rpm2cpio command at the root of the machine? That would automatically dump the required files. Maybe try it with the previous version noted in yum.log – Aaron D. Marasco Sep 29 '18 at 20:19

I just experience the same issue. it took me hours to find the issue and solve it. my case is interrupt the yum update and the last yum.log record is just like you

Oct 22 19:04:36 Updated: 1:grub2-pc-modules-2.02-0.65.el7.centos.2.noarch
Oct 22 19:04:36 Updated: tzdata-2018e-3.el7.noarch
Oct 22 19:04:37 Updated: bash-4.2.46-30.el7.x86_64
Oct 22 19:04:37 Updated: nss-softokn-freebl-3.36.0-5.el7_5.x86_64

I searched and tried the all the solutions but no luck just like you. then I read the rpm source and found in the rpm/rpmio/digest_nss.c

    _nss_ctx = NSS_InitContext(NULL, NULL, NULL, NULL, NULL, flags);
    if (_nss_ctx == NULL) {
    if (NSS_NoDB_Init(NULL) != SECSuccess) {
        rpmlog(RPMLOG_ERR, _("Failed to initialize NSS library\n"));
        rc = -1;
    } else {
        _crypto_initialized = 1;
    sigaction(SIGPIPE, &oact, NULL);

    /* Register one post-fork handler per process */
    if (_new_process) {
    if (pthread_atfork(NULL, NULL, at_forkchild) != 0) {
        rpmlog(RPMLOG_WARNING, _("Failed to register fork handler: %m\n"));
    _new_process = 0;
    return rc;

then I tried with code like this to verify

#include <stdio.h>
#include <nss.h>

int main() {
    NSSInitContext * _nss_ctx = NULL;
    printf("hello world!\n");
    _nss_ctx = NSS_InitContext(NULL, NULL, NULL, NULL, NULL, flags);
    if(_nss_ctx == NULL){
    return 0;

and got the NSS_InitContext is not referenced. ~~ so it is clear the lib version is not match

wget both nss-3.36.0-7.el7_5.x86_64.rpm and nspr-4.13.1-1.0.el7_3.x86_64.rpm (my system is centos7)

using rpm2cpio *rpm | cpio -idmv to extract the file and copy to /usr

run rpm still got the error

version `NSSUTIL_3.31' not found (required by /lib64/libnss3.so)

wget the nss-util-3.36.0-1.el7_5.x86_64.rpm and do a more rpm2cpio and copy

then everything get ok ~ hope this can help you

  • thx all the same though I have already reinstall my centos7,maybe next time I will try your solution. – rangercyh Oct 30 '18 at 2:16

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.