Bug 2345199 - Dnf crashes while loading TOML file
Summary: Dnf crashes while loading TOML file
Keywords:
Status: CLOSED DUPLICATE of bug 2330306
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf5
Version: 41
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: rpm-software-management
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-02-12 14:04 UTC by lucacorbioli12345
Modified: 2025-02-13 13:23 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-02-13 13:19:05 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description lucacorbioli12345 2025-02-12 14:04:15 UTC
Executing dnf in any way returns the error message "Loading system state TOML file /usr/lib/sysimage/libdnf5/nevras.toml failed (see dnf5-system-state(7)): basic_string::_M_create".
The file "nevras.toml" is an empty file in my system. I haven't messed in any way with this file.
I keep my system updated and the last time I used dnf successfully was on the 5th of February.
I tried simple troubleshooting steps like rebooting the PC, checking for any new network policy and checking for a faulty Wifi Adapter but i still haven't solved the problem.

Reproducible: Always

Steps to Reproduce:
1.sudo dnf install firefox
Actual Results:  
Loading system state TOML file /usr/lib/sysimage/libdnf5/nevras.toml failed (see dnf5-system-state(7)): basic_string::_M_create

Expected Results:  
It is already installed

Comment 1 Petr Pisar 2025-02-12 15:43:52 UTC
This can happen when DNF crashes leaving that file half-updated, possible empty. E.g. when a disk space runs out, or a user kills the DNF process. Subsequent DNF invocation that resort to this error about inability of not loading the invalid TOML file. Is that your case?

Unless you have a backup of that file, simply remove it. It's quite possible that DNF will complain about other files. Once you remove all of them, DNF should work again. The downside is that you will loose data that were stored in those files, like DNF history, package installation reason, etc.

Upstream has a tickets <https://github.com/rpm-software-management/dnf5/issues/1609>, <https://github.com/rpm-software-management/dnf5/issues/1610> to make handling the TOML files more resilient.

Comment 2 lucacorbioli12345 2025-02-13 12:00:28 UTC
(In reply to Petr Pisar from comment #1)
> This can happen when DNF crashes leaving that file half-updated, possible
> empty. E.g. when a disk space runs out, or a user kills the DNF process.
> Subsequent DNF invocation that resort to this error about inability of not
> loading the invalid TOML file. Is that your case?
> 
> Unless you have a backup of that file, simply remove it. It's quite possible
> that DNF will complain about other files. Once you remove all of them, DNF
> should work again. The downside is that you will loose data that were stored
> in those files, like DNF history, package installation reason, etc.
> 
> Upstream has a tickets
> <https://github.com/rpm-software-management/dnf5/issues/1609>,
> <https://github.com/rpm-software-management/dnf5/issues/1610> to make
> handling the TOML files more resilient.

Thanks a lot. Only had to remove nevras.toml to make it work.

The data is lost as you said but it's not affecting functionality so it's no big deal.
The problem might have been a crash of the Fedora's "Software" application while restarting.

Probable Cause Note:
I used "Software" to update the system the other day before using dnf and receiving the error.
After I rebooted the machine I didn't even check if it really updated. 
Maybe that was what caused the problem because I checked this morning to try to find the issue and
Software still says that it needs to update.
I received no error message so I assumed it had worked but it may have crashed.
Leaving this here in case anyone else finds this issue.

Thank you for your time Petr.

Comment 3 Petr Pisar 2025-02-13 13:19:05 UTC

*** This bug has been marked as a duplicate of bug 2330306 ***


Note You need to log in before you can comment on or make changes to this bug.