Regression in [0] which re-introduced #2931.
Accessing environment variables must always null check the result.
Resolve by checking the result as well as replacing $HOME
access with a function that falls back to `passwd::pw_dir`.
Also add code-comments to to clarify the current behavior.
[0]: b308b360eb