src/Composer/Downloader/VcsDownloader.php
public function download(PackageInterface $package, $path)
    {
        if (!$package->getSourceReference()) {
            throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
        }

        $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>): ", false);
        $this->filesystem->emptyDirectory($path);

        $urls = $package->getSourceUrls();
        while ($url = array_shift($urls)) {
            try {
                if (Filesystem::isLocalPath($url)) {
                    // realpath() below will not understand
                    // url that starts with "file://"
                    $needle = 'file://';
                    $isFileProtocol = false;
                    if (0 === strpos($url, $needle)) {
                        $url = substr($url, strlen($needle));
                        $isFileProtocol = true;
                    }

                    // realpath() below will not understand %20 spaces etc.
                    if (false !== strpos($url, '%')) {
                        $url = rawurldecode($url);
                    }

                    $url = realpath($url);

                    if ($isFileProtocol) {
                        $url = $needle . $url;
                    }
                }
                $this->doDownload($package, $path, $url);
                break;
            } catch (\Exception $e) {
                // rethrow phpunit exceptions to avoid hard to debug bug failures
                if ($e instanceof \PHPUnit_Framework_Exception) {
                    throw $e;
                }
                if ($this->io->isDebug()) {
                    $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
                } elseif (count($urls)) {
                    $this->io->writeError('    Failed, trying the next URL');
                }
                if (!count($urls)) {
                    throw $e;
                }
            }
        }
    }
public function download(PackageInterface $package, $path)
    {
        if (!$package->getSourceReference()) {
            throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
        }

        $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>): ", false);
        $this->filesystem->emptyDirectory($path);

        $urls = $package->getSourceUrls();
        while ($url = array_shift($urls)) {
            try {
                if (Filesystem::isLocalPath($url)) {
                    // realpath() below will not understand
                    // url that starts with "file://"
                    $needle = 'file://';
                    $isFileProtocol = false;
                    if (0 === strpos($url, $needle)) {
                        $url = substr($url, strlen($needle));
                        $isFileProtocol = true;
                    }

                    // realpath() below will not understand %20 spaces etc.
                    if (false !== strpos($url, '%')) {
                        $url = rawurldecode($url);
                    }

                    $url = realpath($url);

                    if ($isFileProtocol) {
                        $url = $needle . $url;
                    }
                }
                $this->doDownload($package, $path, $url);
                break;
            } catch (\Exception $e) {
                // rethrow phpunit exceptions to avoid hard to debug bug failures
                if ($e instanceof \PHPUnit_Framework_Exception) {
                    throw $e;
                }
                if ($this->io->isDebug()) {
                    $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
                } elseif (count($urls)) {
                    $this->io->writeError('    Failed, trying the next URL');
                }
                if (!count($urls)) {
                    throw $e;
                }
            }
        }
    }
{@inheritDoc}