def _get_user_dir(self):
        '''
        Get the user's home directory.
        '''
        try:
            # This should work in both Windows and Unix environments
            for envname in ['USERPROFILE', 'HOME']:
                user_dir = os.getenv(envname)
                if user_dir is not None:
                    return user_dir
        except KeyboardInterrupt as e:
            raise e
        except Exception:
            pass

        return ''