DNF command fails when run as a non root user

Solution Verified - Updated -

Issue

DNF commands when run as a non-root user, it is failing with the below error:

# dnf list
Traceback (most recent call last):
  File "/usr/bin/dnf", line 62, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 201, in user_main
    errcode = main(args)
  File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 66, in main
    with dnf.cli.cli.BaseCli(conf_class()) as base:
  File "/usr/lib/python3.6/site-packages/dnf/conf/config.py", line 210, in __init__
    config = libdnf.conf.ConfigMain()
  File "/usr/lib64/python3.6/site-packages/libdnf/conf.py", line 1402, in __init__
    this = _conf.new_ConfigMain()
RuntimeError: addFromFile(): Can't open file
Exception ignored in: <bound method MainConf.__del__ of <dnf.conf.config.MainConf object at 0x151254120cc0>>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/dnf/conf/config.py", line 236, in __del__
    for file_name in self.tempfiles:
  File "/usr/lib/python3.6/site-packages/dnf/conf/config.py", line 66, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(self.__class__, name))
AttributeError: '<class 'dnf.conf.config.MainConf'>' object has no attribute 'tempfiles'

Environment

  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content