protected function getHomeDir()
    {
        $home = getenv('SURF_HOME');
        if (! $home) {
            if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                if (! getenv('APPDATA')) {
                    throw new \RuntimeException('The APPDATA or SURF_HOME environment variable must be set for composer to run correctly');
                }
                $home = Files::concatenatePaths([getenv('APPDATA'), 'Surf']);
            } else {
                if (! getenv('HOME')) {
                    throw new \RuntimeException('The HOME or SURF_HOME environment variable must be set for composer to run correctly');
                }
                $home = Files::concatenatePaths([getenv('HOME'), '.surf']);
            }
        }
        $this->ensureDirectoryExists($home);

        return $home;
    }