Nix: SQLite statement 'delete from ValidPaths where path = ?;': constraint failed

Created on 9 Jun 2018  ยท  5Comments  ยท  Source: NixOS/nix

I run nix within proot on a machine where I don't own /nix. The actual store is in /tmp for space reasons, and some files were removed by something else. When I run nix-store --verify --repair --check-contents I get a sqlite error:

$ nix-store --verify --repair --check-contents
[ snip ]
path '/nix/store/580y11zq14xag6ybrvzcbr7k93naman4-SDL2-2.0.8' disappeared, removing from database...
path '/nix/store/rk71nxcvkrlr1bavp7zic074w5blzc9i-glibc-iconv-2.27' disappeared, removing from database...
path '/nix/store/lb3kkvyylnbcxn5jad9i11szxlhkpkjq-glibc-2.27-dev' disappeared, but it still has valid referrers!
copying path '/nix/store/lb3kkvyylnbcxn5jad9i11szxlhkpkjq-glibc-2.27-dev' from 'https://cache.nixos.org'...
path '/nix/store/09fyb8wyijhqpw3rwymssbbn1kxwyziv-linux-headers-4.15' disappeared, removing from database...
error: executing SQLite statement 'delete from ValidPaths where path = ?;': constraint failed (in '/nix/var/nix/db/db.sqlite')

I am pretty confident it is not a problem linked to proot since someone else on irc confirmed having met the same issue. https://logs.nix.samueldr.com/nixos/2018-06-09#1281332;
nix version: 2.0.2

bug

Most helpful comment

I hit the same message from nix-store --verify --repair --check-contents after my (raging) manual removing of some files in /nix/store (the actual command I shouldn't have done: rm -rf /nix/store/*redmine*).
I was able to get it working again with something like this:

sqlite3 /nix/var/nix/db/db.sqlite .dump | sed -e '/redmine/d' | sqlite3 /tmp/db.sqlite
mv /tmp/db.sqlite /nix/var/nix/db/db.sqlite

HTH.

All 5 comments

I hit the same message from nix-store --verify --repair --check-contents after my (raging) manual removing of some files in /nix/store (the actual command I shouldn't have done: rm -rf /nix/store/*redmine*).
I was able to get it working again with something like this:

sqlite3 /nix/var/nix/db/db.sqlite .dump | sed -e '/redmine/d' | sqlite3 /tmp/db.sqlite
mv /tmp/db.sqlite /nix/var/nix/db/db.sqlite

HTH.

I'm hitting this issue as well, but I don't know what to delete, because I haven't deleted anything manually from the store.

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-went-to-systemd-emergency-mode/5647/7

I get this every now and again when I do a nixos-rebuild switch --upgrade and it runs out of disk space midway

After running sudo nix-collect-garbage -d a few times I reached a fix point and my error message is of the form:

~ โฏ sudo nix-collect-garbage -d
removing old generations of profile /nix/var/nix/profiles/per-user/root/channels
removing old generations of profile /nix/var/nix/profiles/per-user/nick/nix-home
removing old generations of profile /nix/var/nix/profiles/per-user/nick/channels
removing old generations of profile /nix/var/nix/profiles/per-user/nick/profile
removing old generations of profile /nix/var/nix/profiles/per-user/nick/home-manager
removing old generations of profile /nix/var/nix/profiles/system
finding garbage collector roots...
deleting garbage...
0 store paths deleted, 0.00 MiB freed
error: executing SQLite statement 'delete from ValidPaths where path = ?;': constraint failed (in '/nix/var/nix/db/db.sqlite')

I suspect what happened was the state of the filesystem for the nix store and the db became inconsistent during my botched upgrade. sudo nix-store --verify --repair --check-contents doesn't seem to reconcile this or fix anything though. Is there a way I can get more information from nix-collect-garbage? I tried this

~ โฏ sudo nix-store --gc --verbose
finding garbage collector roots...
deleting garbage...
0 store paths deleted, 0.00 MiB freed
error: executing SQLite statement 'delete from ValidPaths where path = ?;': constraint failed (in '/nix/var/nix/db/db.sqlite')

but as you can see the error message is the same.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaibhavsagar picture vaibhavsagar  ยท  3Comments

LisannaAtHome picture LisannaAtHome  ยท  3Comments

bflyblue picture bflyblue  ยท  3Comments

ihsanturk picture ihsanturk  ยท  3Comments

eqyiel picture eqyiel  ยท  3Comments