Subject: "guix gc --verify" fails with "FOREIGN KEY constraint failed"

From: Ingo Ruhnke <[email-masked]>
Date: Wed, 17 Jul 2019 19:12:02 +0200

I am using guix on Ubuntu 19.04, due to some unrelated BTRFS problems I
needed to free some space and did a quick:

    $ rm -rv /gnu/store/*libreoff*

This expectedly confuses guix a little and leads to error messages such as
this which make it impossible to reinstall any packages:

    $ guix install libreoffice
    guix install: warning: Consider running 'guix pull' followed by
    'guix package -u' to get up-to-date packages and security updates.

    guix install: error: opening file
`/gnu/store/kmyp9i01aci0azxwcll41kmn347616q7-libreoffice-orcus.patch.drv':
No such file or directory

However trying to clean up the issue with "guix gc --verify" unexpectedly
fails as well, this time with a failed SQLite constraint, this seems like a
bug:

    $ guix gc --verify
    reading the store...
    checking path existence...
    path
`/gnu/store/96ry03xc73c67xs7aj2pnird7icnk578-libreoffice-6.1.5.2.drv'
disappeared, but it still has valid referrers!
    path
`/gnu/store/a1hnx6vgwlnqf4fshfln9ljnp9d8y9pl-libreoffice-6.1.5.2.drv'
disappeared, removing from database...
    guix gc: error: executing SQLite statement: FOREIGN KEY constraint
failed

    $ guix --version
    guix (GNU Guix) 84d7784afe00dfc23c7feeb7ede6bce73406760b