Mac Ports upgrade error Can’t map the URL ‘file://.’ to a port description file (“Could not find Portfile in /”)

When I was trying to upgrade my packages using the macports port command, I got the following error

Can’t map the URL ‘file://.’ to a port description file (“Could not find Portfile in /“).
Please verify that the directory and portfile syntax are correct.
To use the current port, you must be in a port’s directory.
(you might also see this message if a pseudo-port such as
outdated or installed expands to no ports).
Goodbye

Using the following command resolved the issue

sudo port upgrade outdated