Problems logging in after OS (GnuPG) upgrade


Today I helped a friend; after upgrading to Ubuntu 18.04 he became unable to log in to his Mailpile.

We tracked the problem down to the GnuPG 2.x key-chain migration code, which had not automatically migrated his secret keys from the old GnuPG 1.4 format to the new 2.x format.

Running gpg --list-secret-keys in a shell triggered the migration, and everything worked fine after that. I thought this was worth documenting here in case anyone else has the same problem.