What can I do about a BadStorePath error from nix-store --verify?

I had some bad RAM and it corrupted some data. At least, that’s almost certainly the culprit in this weird nix-store error. I’m trying to fix up corrupt data in the nix store, using sudo nix-store --verify --repair, but I get this error:

reading the Nix store...
checking path existence...
error: --- BadStorePath ------------------------------------------------------------------- nix-store
path '/ni�/store/gy0wazd46hbw67qzv17d685z0415j95n-gtk+-2.24.32.drv' is not in the Nix store

Obviously ni� is not nix, but I don’t know what I can do about this error. What is it that’s looking for that derivation, and how can I fix this?

ouch! . nix-store command has a few switch to try and repair the nix store

nix-store --verify --check-contents --repair

maybe also consider dropping to single user mode, or boot from a rescue system to do a fsck of the complete file system and see how damaged it is.

Backup what you can before this, as in somecases, that can actually makes things worse (unbootable).

may help, but if your system has basically corrupted the filesystem and/or the sqlite database - nix stores quite a bit of metadata inside of it… if it corrupted i’m not sure if it can be recreated…

if your on nixos, rebuilding the entire has worked for me once…

nixos-rebuild switch --repair

you can find out some the switches and what they do here Introduction - Nix Reference Manual

good luck! Ram corruption is never nice…one year ECC ram will be standard on everything… (2038)

what hardware are you using, so i can avoid it.

But the problem I’m having is exactly with the nix-store command. I can’t run sudo nix-store --verify --check-contents --repair, since this is what happens:

reading the Nix store...
checking path existence...
error: --- BadStorePath ------------------------------------------------------------------- nix-store
path '/ni�/store/gy0wazd46hbw67qzv17d685z0415j95n-gtk+-2.24.32.drv' is not in the Nix store

What I need to know is, what is nix-store reading? Some kind of manifest somewhere? And how can I find that bad path and fix it?

nixos-rebuild switch --repair seems to have worked. But afterwards sudo nix-store --verify --check-contents --repair still gives the same error.

It’s more than likely reading the contents of the sqllite database. I’ve not done any low level recovery or hacking the database directly…

nix-store --dump-db > db.txt

can dump the db to a text file , that might first step more clues, depending on the degree’s of corruption, you maybe be able to fix it, backup your old db and reload it back it, if it is indeed the case that this DB is corrupted.

as i said… ‘ouch’.

as we are in nixos land, there’s always an option, starting from scratch, using your old configuration files, and rebuilding you whole system from ‘amost’ scratch…that’s the whole point of nix/OS, that massive system corruption, or memory errors, you can at least rebuild the whole thing… and reinstall your data…and your back on the road… :slight_smile:

Yep I just had to reinstall my whole system.

ok, well at least nixos makes it fairly trivial to rebuild you entire system from scratch, if you capture the running state of your system in your configuration.nix. Let us know how you get on…