I’m on nixos unstable. When i run sudo nixos-rebuild switch --upgrade-all i get:
unpacking channels...
unpacking channels...
error (ignored): error: opening file '/nix/store/836rk5b8236sbaf02x258v8ck52a2q21-gnused-4.9.drv': No such file or directory
error (ignored): error: opening file '/nix/store/r1r79hz4bz63app4xamd0k9f8hw2jm1p-coreutils-9.4.drv': No such file or directory
error (ignored): error: opening file '/nix/store/xvpf6k12wmv7z5hp9y4m3l8a33m3mriy-util-linux-2.39.3.drv': No such file or directory
error (ignored): error: opening file '/nix/store/7wis4yv7kz1xgpz2rcc5h6446ba80pvy-gnugrep-3.11.drv': No such file or directory
error (ignored): error: opening file '/nix/store/q6s4pv3ck6qrhzilcwll41jpvsl14dbk-install-shell-files.drv': No such file or directory
error (ignored): error: opening file '/nix/store/04s1fzza11b158xhdhbcg45pka1q6c6j-jq-1.7.1.drv': No such file or directory
error: opening file '/nix/store/4vx0hvfmnwvsc7fif345xs9zdjaxkkpr-stdenv-linux.drv': No such file or directory
building Nix...
building the system configuration...
error (ignored): error: opening file '/nix/store/21x2fn21dsz0cm634qfirck59rqidzvp-append-initrd-secrets.drv': No such file or directory
error (ignored): error: opening file '/nix/store/4vx0hvfmnwvsc7fif345xs9zdjaxkkpr-stdenv-linux.drv': No such file or directory
error: opening file '/nix/store/04s1fzza11b158xhdhbcg45pka1q6c6j-jq-1.7.1.drv': No such file or directory
The rebuild fails and i can’t change my system because of that. The last successful rebuild that i witnessed was my change to plasma6. I don’t know, if this could be the cause of it.
I never encountered an error like this, how can i fix this?
Thank you. I ran sudo nix-store --verify --repair --check-contents multiple times. The output was usually different from time to time but it always ended with an error. I then ran sudo nixos-rebuild switch --upgrade-all in between to see if this helps but it also failed everytime.
For example, i get this:
sudo nix-store --verify --repair --check-contents
reading the Nix store...
checking path existence...
path '/nix/store/0aws2mi4gl1x1xmdbndicbnvilqrqgji-nil-2023-08-09-vendor.tar.gz.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/0aws2mi4gl1x1xmdbndicbnvilqrqgji-nil-2023-08-09-vendor.tar.gz.drv'
path '/nix/store/b5kb1rjaakhvs0nccwvv2586qd2m73bn-etc-fish-config.fish.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/b5kb1rjaakhvs0nccwvv2586qd2m73bn-etc-fish-config.fish.drv'
path '/nix/store/0br1xgjy90jwyxdpadfqvilx81nkrnql-fishplugin-foreign-env-unstable-2020-02-09.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/0br1xgjy90jwyxdpadfqvilx81nkrnql-fishplugin-foreign-env-unstable-2020-02-09.drv'
path '/nix/store/0csmicmam9pnp2c1zarfg9cz9w8ybbg6-python3.11-mypy-extensions-1.0.0.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/0csmicmam9pnp2c1zarfg9cz9w8ybbg6-python3.11-mypy-extensions-1.0.0.drv'
path '/nix/store/1k7h6956backv83y3hnz7vywb9paly6i-libbytesize-2.10.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/1k7h6956backv83y3hnz7vywb9paly6i-libbytesize-2.10.drv'
path '/nix/store/7hv3pv32pwhm6bs72923ivd5x02h5q94-bottom-0.9.6.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/7hv3pv32pwhm6bs72923ivd5x02h5q94-bottom-0.9.6.drv'
path '/nix/store/v53ywncl56x2g86g04z90ddyxh34rpy2-systemd-boot-builder.py.drv' disappeared, but it still has valid referrers!
warning: cannot repair path '/nix/store/v53ywncl56x2g86g04z90ddyxh34rpy2-systemd-boot-builder.py.drv'
path '/nix/store/bx7sfis07jbkbl5sq14xvzdshlqzhbnl-bootspec-1.0.0.drv' disappeared, removing from database...
error: executing SQLite statement 'delete from ValidPaths where path = '/nix/store/bx7sfis07jbkbl5sq14xvzdshlqzhbnl-bootspec-1.0.0.drv';': constraint failed, FOREIGN KEY constraint failed (in '/nix/var/nix/db/db.sqlite')
and this:
sudo nixos-rebuild switch --upgrade-all
unpacking channels...
unpacking channels...
error (ignored): error: opening file '/nix/store/q6s4pv3ck6qrhzilcwll41jpvsl14dbk-install-shell-files.drv': No such file or directory
error (ignored): error: opening file '/nix/store/836rk5b8236sbaf02x258v8ck52a2q21-gnused-4.9.drv': No such file or directory
error (ignored): error: opening file '/nix/store/7wis4yv7kz1xgpz2rcc5h6446ba80pvy-gnugrep-3.11.drv': No such file or directory
error (ignored): error: opening file '/nix/store/4vx0hvfmnwvsc7fif345xs9zdjaxkkpr-stdenv-linux.drv': No such file or directory
error: opening file '/nix/store/r1r79hz4bz63app4xamd0k9f8hw2jm1p-coreutils-9.4.drv': No such file or directory
building Nix...
error: opening file '/nix/store/17gdfyx2nzzcbhh8c2fm6zm8973nnrsd-stdenv-linux.drv': No such file or directory
Is there something else i can do (like “force rebuild from scratch” if something like this is possible) or do i have to reinstall Nixos?
I probably wouldn’t recommend hand-editing the database unless you know what you’re doing. Trying to remove the packges that refer to these .drvs and rebuilding a bunch (so you also reevaluate the .drvs) seems more reasonable, albeit probably more effort.
Pretty serious bug IMO, this kind of defies the purpose of nix.