Trying to install git in a FreeBSD 12.2 jail produced this error
Turns out it's not unusal, and it probably means that your password database is out of sync with /etc/passwd.
One solution is to simply run vipw, save and exit without making any changes.
vipw natually opens vi as the editor, once open all you need to do is save & exit using the command :wq (that's colon, lower case 'w', lower case 'q')
Once returned to the prompt, retry the pkg command and it should be successful.
Ref: FreeBSD Forums