On Red Hat 9.5 as a user I face:

```bash
yum install htop
```
<details>
<summary>Output:</summary>

```
Traceback (most recent call last):
File "/usr/bin/yum", line 62, in <module>
main.user_main(sys.argv[1:], exit_code=True)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 201, in user_main
errcode = main(args)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 66, in main
with dnf.cli.cli.BaseCli(conf_class()) as base:
File "/usr/lib/python3.9/site-packages/dnf/conf/config.py", line 228, in __init__
config = libdnf.conf.ConfigMain()
File "/usr/lib64/python3.9/site-packages/libdnf/conf.py", line 1122, in __init__
_conf.ConfigMain_swiginit(self, _conf.new_ConfigMain())
RuntimeError: addFromFile(): Can't open file
Exception ignored in: <function MainConf.__del__ at 0x7ffff47a45e0>
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/dnf/conf/config.py", line 254, in __del__
for file_name in self.tempfiles:
File "/usr/lib/python3.9/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'
```
</details>

How to solve this issue?
May 10, 5:20pm

The error you're encountering on Red Hat Enterprise Linux (RHEL) 9.5 when running yum install htop is related to a corrupted or misconfigured DNF (Dandified YUM) configuration. This often happens due to:

  • A missing or corrupted /etc/dnf/dnf.conf file.
  • Permission issues with DNF configuration files.
  • A broken DNF cache or temporary files.

How to Fix the Issue

1. Check DNF Configuration File

Run the following command to verify if /etc/dnf/dnf.conf exists and is readable:

bash
ls -l /etc/dnf/dnf.conf

If it's missing or corrupted, restore it from a backup or recreate it:

bash
sudo cp /usr/share/dnf/dnf.conf /etc/dnf/dnf.conf

2. Clear DNF Cache

Corrupted cache files can cause this issue. Clear the cache with:

bash
sudo dnf clean all

3. Reinstall DNF

If the issue persists, reinstall DNF:

bash
sudo dnf reinstall dnf -y

4. Check for Broken Dependencies

Run:

bash
sudo dnf check

If broken dependencies are found, fix them with:

bash
sudo dnf repair

5. Use dnf Instead of yum

Since RHEL 9 uses dnf as the default package manager, try:

bash
sudo dnf install htop

6. Check for SELinux Issues

If SELinux is enforcing, it might block DNF operations. Temporarily set it to permissive mode to test:

bash
sudo setenforce 0

Then retry the installation. If it works, adjust SELinux policies:

bash
sudo ausearch -c 'dnf' --raw | audit2allow -M my-dnf
sudo semodule -i my-dnf.pp

7. Verify Python Dependencies

DNF relies on Python. Ensure Python 3.9 and required libraries are intact:

bash
sudo dnf reinstall python3-dnf -y

8. Check for Filesystem Errors

Run a filesystem check:

bash
sudo fsck -f /

9. Reinstall libdnf

If the error persists, reinstall libdnf:

bash
sudo dnf reinstall libdnf -y

Final Test

After applying the fixes, test with:

bash
sudo dnf install htop

If the issue persists, check /var/log/dnf.log or /var/log/messages for detailed errors.

May 10, 5:20pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Le Chat can make mistakes. Check answers. Learn more