I have installed gpg version 2.2.17 from source.
When I run gpg --card-status gpg reports:
gpg: WARNING: server 'gpg-agent' is older than us (2.2.4 < 2.2.17).
gpg: Note: Outdated servers may lack important security fixes.
gpg: Note: Use the command "gpgconf --kill all" to restart them.
I have tried running the gpgconf command that was suggested but the problem persists. I have also tried uninstalling gpg2 from the Ubuntu repositories using sudo apt remove gpg2 and then rerunning gpgconf --kill all to no avail.
For good measure I even tried restarting my computer to kill the old version of gpg-agent.
Additionally, gpg-agent --version reports:
gpg-agent (GnuPG) 2.2.17
libgcrypt 1.8.4
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.