GPG errors with dnf (and maybe a Python problem?)

Hi guys! I have a question regarding GPG. Every time I try to install or upgrade something with dnf, I have this gpg error, and I have to use --nogpgcheck to make it work. There’s a way to fix this problem? It’s something to do with Python? Im asking this cause some of my Python scripts stop to working at the same time

I can’t uninstall gpg and reinstall it, since it’s a dependency for dnf itself

Any thoughts?

Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 201, in user_main
    errcode = main(args)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 67, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 106, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 130, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 176, in resolving
    base.do_transaction(display=displays)
  File "/usr/lib/python3.8/site-packages/dnf/cli/cli.py", line 235, in do_transaction
    self.gpgsigcheck(install_pkgs)
  File "/usr/lib/python3.8/site-packages/dnf/cli/cli.py", line 287, in gpgsigcheck
    self._get_key_for_package(po, fn)
  File "/usr/lib/python3.8/site-packages/dnf/base.py", line 2321, in _get_key_for_package
    keys = dnf.crypto.retrieve(keyurl, repo)
  File "/usr/lib/python3.8/site-packages/dnf/crypto.py", line 177, in retrieve
    keyinfos = rawkey2infos(handle)
  File "/usr/lib/python3.8/site-packages/dnf/crypto.py", line 158, in rawkey2infos
    with pubring_dir(pb_dir), Context() as ctx:
  File "/usr/lib64/python3.8/site-packages/gpg/core.py", line 220, in __init__
    self.protocol = protocol
  File "/usr/lib64/python3.8/site-packages/gpg/core.py", line 169, in __setattr__
    super(GpgmeWrapper, self).__setattr__(key, value)
  File "/usr/lib64/python3.8/site-packages/gpg/core.py", line 1123, in protocol
    errorcheck(gpgme.gpgme_engine_check_version(value))
  File "/usr/lib64/python3.8/site-packages/gpg/errors.py", line 129, in errorcheck
    raise GPGMEError(retval, extradata)
gpg.errors.GPGMEError: GPGME: Invalid crypto engine

Are you running a freshly installed Fedora or did you upgrade from a lower release?
try:
dnf update fedora-* --nogpgcheck --best --allowerasing

after that, try to update with dnf without --nogpgcheck and see it solves it

I already did it. I had this problem before Upgrade to 32 from 31, and I had to use --nogpgcheck in the ocasion

sudo dnf list fedora-*

What does that output?

Here it is

Last metadata expiration check: 1:26:37 ago on qua 06 mai 2020 11:03:35.
Installed Packages
fedora-bookmarks.noarch                         28-7.fc32                      @fedora 
fedora-gpg-keys.noarch                          32-2                           @updates
fedora-logos.x86_64                             30.0.2-4.fc32                  @fedora 
fedora-release-common.noarch                    32-2                           @updates
fedora-release-kde.noarch                       32-2                           @updates
fedora-repos.noarch                             32-2                           @updates
Available Packages
fedora-business-cards.noarch                    2.0-2.fc32                     fedora  
fedora-chromium-config.noarch                   1.1-4.fc32                     fedora  
fedora-coreos-config-transpiler.x86_64          0.5.0-1.fc32                   fedora  
fedora-coreos-config-transpiler-nonlinux.noarch 0.5.0-1.fc32                   fedora  
fedora-developer-portal.noarch                  1.0.0-0.8.git7fc490c.fc32      updates 
fedora-dockerfiles.x86_64                       0-0.27.giteab04ff.fc32         fedora  
fedora-easy-karma.noarch                        0-0.43.20191206git56f1e97.fc32 fedora  
fedora-gather-easyfix.noarch                    0.2.1-81.fc32                  fedora  
fedora-gnat-project-common.noarch               3.13-3.fc32                    fedora  
fedora-icon-theme.noarch                        1.0.0-27.fc32                  fedora  
fedora-jam-backgrounds.noarch                   1.0.1-0.14.git8db10f1.fc32     fedora  
fedora-jam-backgrounds-gnome.noarch             1.0.1-0.14.git8db10f1.fc32     fedora  
fedora-jam-backgrounds-kde.noarch               1.0.1-0.14.git8db10f1.fc32     fedora  
fedora-jam-backgrounds-single.noarch            1.0.1-0.14.git8db10f1.fc32     fedora  
fedora-jam-backgrounds-xfce.noarch              1.0.1-0.14.git8db10f1.fc32     fedora  
fedora-jam-kde-theme.noarch                     1.0.1-14.fc31                  fedora  
fedora-kickstarts.noarch                        0.31.0-0.3.fc32                fedora  
fedora-logos-httpd.noarch                       30.0.2-4.fc32                  fedora  
fedora-messaging.noarch                         2.0.1-2.fc32                   fedora  
fedora-messaging-doc.noarch                     2.0.1-2.fc32                   fedora  
fedora-obsolete-packages.noarch                 32-44                          fedora  
fedora-packager.noarch                          0.6.0.4-1.fc32                 fedora  
fedora-packager-yubikey.noarch                  0.6.0.4-1.fc32                 fedora  
fedora-release.noarch                           32-2                           updates 
fedora-release-cinnamon.noarch                  32-2                           updates 
fedora-release-cloud.noarch                     32-2                           updates 
fedora-release-container.noarch                 32-2                           updates 
fedora-release-coreos.noarch                    32-2                           updates 
fedora-release-iot.noarch                       32-2                           updates 
fedora-release-matecompiz.noarch                32-2                           updates 
fedora-release-server.noarch                    32-2                           updates 
fedora-release-silverblue.noarch                32-2                           updates 
fedora-release-snappy.noarch                    32-2                           updates 
fedora-release-soas.noarch                      32-2                           updates 
fedora-release-workstation.noarch               32-2                           updates 
fedora-release-xfce.noarch                      32-2                           updates 
fedora-remix-logos.noarch                       1.0.0-17.fc32                  fedora  
fedora-repo-zdicts.noarch                       2004.2-1.fc32                  updates 
fedora-repos-ostree.noarch                      32-2                           updates 
fedora-repos-rawhide.noarch                     32-2                           updates 
fedora-review.noarch                            0.7.5-1.fc32                   fedora  
fedora-review-plugin-ruby.noarch                0.7.5-1.fc32                   fedora  
fedora-review-tests.noarch                      0.7.5-1.fc32                   fedora  
fedora-rpm-macros.noarch                        26-8.fc32                      fedora  
fedora-update-feedback.x86_64                   0.5.3-1.fc32                   updates 
fedora-upgrade.noarch                           32.2-1.fc32                    fedora  
fedora-workstation-backgrounds.noarch           1.1-7.fc32                     fedora  
fedora-workstation-repositories.noarch          32-3.fc32                      fedora

hmmm,

sudo dnf reinstall dnf* *gpg* --nogpgcheck

after that

sudo dnf update

You need to fully update your system

So, this is what happened:

Last metadata expiration check: 1:33:42 ago on qua 06 mai 2020 17:10:50.
No match for argument: dnf_problem
Dependencies resolved.
=======================================================================================================================================================================
 Package                                       Architecture                      Version                                      Repository                          Size
=======================================================================================================================================================================
Reinstalling:
 fedora-gpg-keys                               noarch                            32-2                                         updates                            103 k
 gpgme                                         i686                              1.13.1-7.fc32                                updates                            214 k
 gpgme                                         x86_64                            1.13.1-7.fc32                                updates                            205 k
 gpgmepp                                       x86_64                            1.13.1-7.fc32                                updates                            134 k
 kgpg                                          x86_64                            19.12.1-1.fc32                               fedora                             3.1 M
 libgpg-error                                  i686                              1.36-3.fc32                                  fedora                             206 k
 libgpg-error                                  x86_64                            1.36-3.fc32                                  fedora                             201 k
 libgpg-error-devel                            i686                              1.36-3.fc32                                  fedora                              63 k
 libgpg-error-devel                            x86_64                            1.36-3.fc32                                  fedora                              62 k
 python3-gpg                                   x86_64                            1.13.1-7.fc32                                updates                            262 k
 qgpgme                                        x86_64                            1.13.1-7.fc32                                updates                            242 k

Transaction Summary
=======================================================================================================================================================================

Total download size: 4.7 M
Installed size: 13 M
Is this ok [y/N]: y

Note the line: No match for argument: dnf_problem

After that, sudo dnf update just returned

Last metadata expiration check: 1:34:18 ago on qua 06 mai 2020 17:10:50.
Dependencies resolved.
Nothing to do.
Complete!

To test it, I’ve tried to install any random thing, like Gimp, and the gpg problem persists

Total                                                                                                                                   12 MB/s |  27 MB     00:02     
warning: /var/cache/dnf/fedora-558931b5e76b51a7/packages/babl-0.1.74-1.fc32.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 12c944d0: NOKEY
Fedora 32 - x86_64                                                                                                                     1.6 MB/s | 1.6 kB     00:00    
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 201, in user_main
    errcode = main(args)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 67, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 106, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 130, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.8/site-packages/dnf/cli/main.py", line 176, in resolving
    base.do_transaction(display=displays)
  File "/usr/lib/python3.8/site-packages/dnf/cli/cli.py", line 235, in do_transaction
    self.gpgsigcheck(install_pkgs)
  File "/usr/lib/python3.8/site-packages/dnf/cli/cli.py", line 287, in gpgsigcheck
    self._get_key_for_package(po, fn)
  File "/usr/lib/python3.8/site-packages/dnf/base.py", line 2321, in _get_key_for_package
    keys = dnf.crypto.retrieve(keyurl, repo)
  File "/usr/lib/python3.8/site-packages/dnf/crypto.py", line 177, in retrieve
    keyinfos = rawkey2infos(handle)
  File "/usr/lib/python3.8/site-packages/dnf/crypto.py", line 158, in rawkey2infos
    with pubring_dir(pb_dir), Context() as ctx:
  File "/usr/lib64/python3.8/site-packages/gpg/core.py", line 220, in __init__
    self.protocol = protocol
  File "/usr/lib64/python3.8/site-packages/gpg/core.py", line 169, in __setattr__
    super(GpgmeWrapper, self).__setattr__(key, value)
  File "/usr/lib64/python3.8/site-packages/gpg/core.py", line 1123, in protocol
    errorcheck(gpgme.gpgme_engine_check_version(value))
  File "/usr/lib64/python3.8/site-packages/gpg/errors.py", line 129, in errorcheck
    raise GPGMEError(retval, extradata)
gpg.errors.GPGMEError: GPGME: Invalid crypto engine

sudo cat /var/log/dnf.log | fpaste
sudo cat /var/log/dnf.rpm.log | fpaste

sudo dnf check

Share output of those

Why are you having 32bit packages?

Ok, here we go

sudo cat /var/log/dnf.log | fpaste
Result: https://paste.centos.org/view/746e3d28

sudo cat /var/log/dnf.rpm.log | fpaste
https://paste.centos.org/view/d87f0c49

Why are you having 32bit packages?
TBH, I don’t have an idea, but I have some VFX programs, and maybe one of then needs 32bit packages? Or something related to Wine and Steam? Dunno, just guessing here

Are you now able to install without --nogpgcheck? I see in the logs that some commands were successful without it; which suggests that your observation resolved itself somewhere between the scheduled “dnf makecache” sessions

Hmm no, the problem is still there. And I have another problem now, and I dunno if it’s something related to the first one. Every time I try to use any install script, from any program, I have several bash errors when I start the command with sudo, but with my normal user everything goes fine (obviously I have several permissions problems without sudo)

One example, there’s a Render Engine called Guerilla Render, and every time I try to use the install script using sudo, I have problems like this:

[moco@moco-fedora guerillarender]$ sudo ./install 
[sudo] password for moco: 
./install: line 23: dirname: command not found
./install: line 25: basename: command not found
./install: line 92: grep: command not found
./install: line 92: cut: command not found
./install: line 152: id: command not found
./install: line 152: [: too many arguments
./install: line 195: cat: command not found
./install: line 198: clear: command not found
Guerilla Render  Setup

Press any keys to continue

And it only happens with sudo. It can be something related?

The problem with install scripts are NOT Fedora-specific. You will get better help from vendors of those scripts. Meanwhile, you need to provide information for further troubleshooting.

Hmmm this is strange, cause I already have installed other programs in the same way, and everything went good. There’s a program called Houdini, and it’s the main tool for my work. I already installed it, and I tested the same installer now, and now it doesn’t work. Same version, it worked before, just don’t work
anymore. It’s a recent problem

I’m almost giving up and reinstalling all the system

That sounds good. Please use apps from the Fedora repository for best results and best support. If you’re going to use Apps that are not packaged (install scripts), be careful to separate the installation from system-wide files. Since you are reinstalling… download the latest release of Fedora (32) and start fresh with that

Probably no need to reinstall.

I was hoping you/we would find a more nice answer to this here…

In https://discussion.fedoraproject.org/t/error-while-upgrading-from-31-to-32/74939
I suggested to: sudo “dnf --nogpgcheck update” … and I hope that after that it is not necessary to use --nogpgcheck anymore, but I just don’t know and I wish to know.

But yeah it means you don’t check the packages to be upgraded to be sure it is coming from Fedora and are not changed… which is not ideal.

It’s definettly some kind of bug. I’ve tried now to use the command su in the terminal, and I had this error below:

[moco@moco-fedora etc]$ su
Password: 
bash: register-python-argcomplete: command not found
/usr/libexec/grepconf.sh: line 5: grep: command not found
/usr/libexec/grepconf.sh: line 5: grep: command not found
/usr/libexec/grepconf.sh: line 5: grep: command not found
bash: grep: command not found

In the other report there is:
warning: /var/lib/dnf/system-upgrade/fedora-558931b5e76b51a7/packages/dnf-4.2.19-1.fc32.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 12c944d0: NOKEY

sudo --nogpgcheck update dnf
could be a solution?

Damn, ok I’ve found the problem. I had two environment variables, one in my .bashrc, at my Home folder, and another on /etc/environment

.bashrc
PATH="/opt/pixar/RenderManProServer-23.2/bin:$PATH"

/etc/environment
PATH="/opt/pixar/RenderManProServer-23.2/bin"

One of then was messing up all my system. What is the right way to create an environment variable?

You see that in /etc/environment … :$PATH is missing? (I think)

Thanks for the link, I’ll try it right now! And thanks for your patience guys! I’m happy it will not needed to reinstall all the system hahaha