Nix-collect-garbage is failling

nix-collect-garbage is failling:

sudo nix-collect-garbage --delete-older-than 30d
[sudo] Mot de passe de pierre :
removing old generations of profile /nix/var/nix/profiles/system
removing old generations of profile /nix/var/nix/profiles/per-user/root/profile
removing old generations of profile /nix/var/nix/profiles/per-user/root/channels
removing old generations of profile /nix/var/nix/profiles/per-user/root/profile
removing old generations of profile /nix/var/nix/profiles/per-user/root/channels
finding garbage collector roots...
deleting garbage...
deleting '/nix/store/3nna4a37vlq67d8fqbp8khsh049kyw42-nixos-24.11'
1 store paths deleted, 0.00 MiB freed
error: reading directory '"/nix/store/3nna4a37vlq67d8fqbp8khsh049kyw42-nixos-24.11/nixos/pkgs/development/python-modules/pydash"': Bad message

What can I to resolve this issue?

I tried repair:

sudo nixos-rebuild switch --flake . --show-trace --repair

But it was not helping.

Try the nix-store --verify --check-contents command: nix-store --verify - Nix 2.28.1 Reference Manual

Everything appears to be OK:

$ nix-store --verify --check-contents
reading the Nix store...
checking path existence...
checking link hashes...
checking store hashes...

There are no other messages.

Hmm, do you still get the bad message error when you try to delete it with nix-collect-garbage? That’s a filesystem error, I guess perhaps whatever corruption is happening means the file cannot be deleted? May be a failing disk, make sure you have backups of anything important.

Yes, I was having an issue with my disk. I did a repair and the problem is now gone. :grinning: