From 3e22e1ceda0d794c114bb4688c3fd533908b3842 Mon Sep 17 00:00:00 2001 From: Uladzimir Tsykun Date: Fri, 6 Oct 2023 09:53:39 +0200 Subject: [PATCH] Fix error when vendor dir contains broken symlinks (#11670) --- src/Composer/Util/Filesystem.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 5e90e09f3..7ddcfa69f 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -251,10 +251,13 @@ class Filesystem $directory.' exists and is not a directory.' ); } + + if (is_link($directory) && !@$this->unlinkImplementation($directory)) { + throw new \RuntimeException('Could not delete symbolic link '.$directory.': '.(error_get_last()['message'] ?? '')); + } + if (!@mkdir($directory, 0777, true)) { - throw new \RuntimeException( - $directory.' does not exist and could not be created.' - ); + throw new \RuntimeException($directory.' does not exist and could not be created: '.(error_get_last()['message'] ?? '')); } } }