Macchina-CLI / macchina

A system information frontend with an emphasis on performance.
https://crates.io/crates/macchina
MIT License
1.49k stars 52 forks source link

[BUG] WSL2 openSUSE Tumbleweed zypper packages didn't show up #284

Closed justrico closed 6 months ago

justrico commented 1 year ago

Describe the bug openSUSE Tumbleweed on WSL2 didn't display zypper packages.

To Reproduce Steps to reproduce the behavior:

  1. Launch openSUSE Tumbleweed on WSL2
  2. Execute macchina

Expected behavior Expect macchina to show up zypper packages.

Screenshots Snipaste_2023-04-14_12-33-19

macchina --doctor output Snipaste_2023-04-14_12-42-05

System Information

grtcdr commented 1 year ago

@Gobidev Could this be related to https://github.com/Macchina-CLI/libmacchina/issues/154?

Gobidev commented 1 year ago

Yes, openSUSE uses the ndb database backend for RPM, which is why the file /var/lib/rpm/rpmdb.sqlite doesn't exist and the package count fails. It might be possible to work around this by switching the backend to sqlite manually:

To change the RPM database backend, you need to edit the /usr/lib/rpm/macros file and set the %_db_backend macro to the desired value (such as sqlite or ndb). You may also need to rebuild the RPM database using rpmdb --rebuilddb. However, note that changing the RPM database backend is not recommended unless you have a specific reason to do so. It may cause compatibility issues with other tools that rely on the RPM database format.

When trying this on openSUSE Tumbleweed, I got warning: invalid %_db_backend: sqlite when trying to rebuild the database, so it looks like their build of RPM comes without sqlite support.

Like I said in https://github.com/Macchina-CLI/libmacchina/issues/154, the ideal solution would be to somehow get a package count out of the ndb database, but this is a lot of work. Spawning an rpm process is not really an option for libmacchina, as it takes ~500ms to execute on a modern system.

grtcdr commented 1 year ago

Thanks for the confirmation.

I'm not particularly motivated to work on an implementation for the ndb database, because (1) I'd probably write something that's even slower than spawning the corresponding process and (2) I don't use SUSE technologies. I'm not opposed to including a new dependency for this, though.

Gobidev commented 1 year ago

This was fixed in https://github.com/Macchina-CLI/libmacchina/pull/159, although the rpm-devel package will need to be installed for the detection to work once it is available in macchina.