From 91a1a471dbb6de6708ede5fbc81c6adca82e3049 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 18 Aug 2021 11:25:00 +0200 Subject: [PATCH] Fix path repo bug causing symlinks to be left behind when uninstalling, fixes #10023 --- src/Composer/Downloader/PathDownloader.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index bdcf39984..be1b1262d 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -184,7 +184,14 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter return \React\Promise\resolve(); } - if (realpath($path) === realpath($package->getDistUrl())) { + // ensure that the source path (dist url) is not the same as the install path, which + // can happen when using custom installers, see https://github.com/composer/composer/pull/9116 + // not using realpath here as we do not want to resolve the symlink to the original dist url + // it points to + $fs = new Filesystem; + $absPath = $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path; + $absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : getcwd() . '/' . $package->getDistUrl(); + if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) { if ($output) { $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path"); }