snowfallorg / nix-software-center

A simple gtk4/libadwaita software center to easily install and manage nix packages
GNU General Public License v3.0
529 stars 16 forks source link

Malformed package database: error returned from database: (code: 11) database disk image is malformed #38

Open davidak opened 1 year ago

davidak commented 1 year ago

I installed the new version with the new instructions for NixOS 22.11 (https://github.com/vlinkz/nix-software-center/pull/36/files).

The GUI is stuck on loading and i get an error in terminal.

Screenshot from 2023-03-18 05-34-19

[davidak@gaming:~]$ RUST_BACKTRACE=1 nix-software-center 
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Database(SqliteError { code: 11, message: "database disk image is malformed" })', src/ui/windowloading.rs:107:26
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <nix_software_center::ui::windowloading::WindowAsyncHandler as relm4::component::worker::Worker>::update::{{closure}}
   4: tokio::runtime::task::core::Core<T,S>::poll
   5: tokio::runtime::task::harness::Harness<T,S>::poll
   6: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
   7: tokio::runtime::scheduler::multi_thread::worker::Context::run
   8: tokio::macros::scoped_tls::ScopedKey<T>::set
   9: tokio::runtime::scheduler::multi_thread::worker::run
  10: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  11: tokio::runtime::task::core::Core<T,S>::poll
  12: tokio::runtime::task::harness::Harness<T,S>::poll
  13: tokio::runtime::blocking::pool::Inner::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
^C

To improve UX, the GUI should show the error and not pretend to be loading.

Also, such an error should not happen. It's fine while it's not a stable release, but annoying for users.

I guess to fix it, i have to delete the database and let it create a new one. What database does it mean and where is it? Such a fix can also be shown in the GUI. Maybe have a button "Delete and create new database".

davidak commented 1 year ago

Updated to nix-software-center 0.1.2 on NixOS 22.11.4588.93fddcf640c.

To improve UX, the GUI should show the error and not pretend to be loading.

The GUI now shows an error dialog and don't pretend to be loading.

Screenshot from 2023-06-18 20-22-19

In terminal i see:

ERROR nix_software_center::ui::windowloading > Error getting pkglist: error returned from database: (code: 11) database disk image is malformed

What database does it mean and where is it?

Monitor says it's /home/davidak/.cache/nix-data/nixospkgs.db and two other related files.

Screenshot from 2023-06-18 20-32-07

I guess to fix it, i have to delete the database and let it create a new one.

After deleting the files, the GUI said "Loading..." again, created the files and now it works!

rm /home/davidak/.cache/nix-data/nixospkgs.db*

Such a fix can also be shown in the GUI. Maybe have a button "Delete and create new database".

I think that would be the best solution. Signal does something similar in this case.