Fix issue #54 by making sure $HOME is only used when set

Original issue: https://bugzilla.wikimedia.org/show_bug.cgi?id=62240