NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.33k stars 13.57k forks source link

`error: opening file '/nix/store/....': No such file or directory` on nix store commands #329604

Open mrmagic223325 opened 1 month ago

mrmagic223325 commented 1 month ago

Describe the bug

Some nix commands which operate on the store all return the same error message error: opening file '/nix/store/pgrnz3yny412l4q8s46kw39jf184gn7q-webcord-vencord-4.9.1.drv': No such file or directory

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run nix-collect-garbage -d, nix-store --gc or nix-store --optimise
  2. Wait for command to finish

Expected behavior

There shouldn't be any error messages and the command should just succeed.

Screenshots

image

Additional context

/

Notify maintainers

No idea who maintains these commands or the nix store.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.9.8-zen1, NixOS, 24.11 (Vicuna), 24.11.20240716.ad0b5ee`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.0pre20240709_142e566a`
 - nixpkgs: `/etc/nix/path/nixpkgs`

Add a :+1: reaction to issues you find important.

eclairevoyant commented 1 month ago

Not related to nixpkgs, it's a nix thing. And if you're getting these errors you need to do a store repair, you probably have some disk corruption.

mrmagic223325 commented 1 month ago

Not related to nixpkgs, it's a nix thing. And if you're getting these errors you need to do a store repair, you probably have some disk corruption.

Whats the correct repo for the nix command? I have also tried all different kinds of repair commands for the nix store but none did any change.

eclairevoyant commented 1 month ago

I would suggest running sudo nix-store --verify --repair --check-contents as the repair command (exactly as is).

For help/questions you can get more help on discourse.nixos.org, would probably get more attention than asking here IMO.

mrmagic223325 commented 1 month ago

I would suggest running sudo nix-store --verify --repair --check-contents as the repair command (exactly as is).

I tried the command you suggested. I now get a new error:

error: executing SQLite statement 'delete from ValidPaths where path = '/nix/store/vlkzz3c0ihb0y78c9hvhdpqbi763y4bp-electron-30.0.3.drv';': constraint failed, FOREIGN KEY constraint failed (in '/nix/var/nix/db/db.sqlite')

For help/questions you can get more help on discourse.nixos.org, would probably get more attention than asking here IMO.

I think I'll just reinstall my entire system at this point. Seems like my nix store isn't doing good at all.