Fix error when HOME is not defined.

The purpose of this is to avoid later Dir.chdir{} calls resulting
in the previous directory being changed to, which may no longer
exist.

This change does not break considering the current directory when running
'portupgrade' or 'portinstall' alone.