Skip to content

error: cannot open SQLite database '/nix/var/nix/db/db.sqlite': unable to open database file #140

@milahu

Description

@milahu

i just broke the nix database
by manually running the bwrap call
printed by NP_DEBUG=1 nix-portable nix-shell

bwrap --bind $HOME/.nix-portable/emptyroot / --dev-bind /dev /dev --bind $HOME/.nix-portable/nix /nix --bind /usr /usr --bind /proc /proc --bind /home /home --bind /action.log /action.log --bind /boot/initrd.img-4.19.0-0.bpo.9-amd64 /initrd.img --bind /boot/initrd.img-4.9.0-13-amd64 /initrd.img.old --bind /boot /boot --bind /tmp /tmp --bind /boot/vmlinuz-4.9.0-13-amd64 /vmlinuz.old --bind /etc /etc --bind /root /root --bind /bin /bin --bind /lib64 /lib64 --bind /sys /sys --bind /media /media --bind /srv /srv --bind /run /run --bind /opt /opt --bind /var /var --bind /lost+found /lost+found --bind /lib /lib --bind /boot/vmlinuz-4.19.0-0.bpo.9-amd64 /vmlinuz --bind /mnt /mnt --bind /sbin /sbin --bind /etc/host.conf /etc/host.conf --bind /etc/hosts /etc/hosts --bind /etc/networks /etc/networks --bind /etc/passwd /etc/passwd --bind /etc/group /etc/group --bind /etc/nsswitch.conf /etc/nsswitch.conf --bind /run/systemd/resolve/resolv.conf /run/systemd/resolve/resolv.conf --bind /usr/share/zoneinfo/UCT /usr/share/zoneinfo/UCT --bind $HOME $HOME --bind /etc/ssl/certs/ca-certificates.crt $HOME/.nix-portable/ca-bundle.crt $HOME/.nix-portable/nix/store/j823gnvpxh1fjibycmldrspkk3pgivwp-nix-2.20.6/bin/nix-shell

now nix-portable is broken

$ nix-portable nix-shell
error: cannot open SQLite database '/nix/var/nix/db/db.sqlite': unable to open database file

but the nix database works with sqlite3

$ sqlite3 .nix-portable/nix/var/nix/db/db.sqlite .schema | head -n3
CREATE TABLE ValidPaths (
    id               integer primary key autoincrement not null,
    path             text unique not null,

so maybe the database contents are corrupted?

see my 9MB .nix-portable/nix/var/nix/db/db.sqlite in
https://github.com/milahu/nix-portable-broken-nix-database
(sorry, i dont have the working "before" version)

hard fix:

chmod -R 777 .nix-portable # fix "Permission denied"
rm -rf .nix-portable
nix-portable nix-shell

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions