public static function setupHome($home)
    {
        if (empty($home)) {
            throw new \InvalidArgumentException('Empty home directory encountered.');
        }

        if (false === getenv('COMPOSER')) {
            putenv('COMPOSER=' . $home . DIRECTORY_SEPARATOR . 'composer.json');
        }
        chdir($home);

        // Ensure at least one of the environment variables is available.
        if (!getenv('COMPOSER_HOME') && !getenv('HOME')) {
            putenv('COMPOSER_HOME=' . $home);
        }
    }