Skip to content

Commit

Permalink
Fix error when vendor dir contains broken symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
vtsykun committed Oct 2, 2023
1 parent 64c5bdd commit 2c2d0f4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Composer/Util/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,15 @@ public function ensureDirectoryExists(string $directory)
$directory.' exists and is not a directory.'
);
}
if (!@mkdir($directory, 0777, true)) {
throw new \RuntimeException(
$directory.' does not exist and could not be created.'
);

$error = null;
if (is_link($directory) && !@$this->unlinkImplementation($directory)) {
$error = 'Could not delete symbolic link '.$directory.': '.(error_get_last()['message'] ?? '');
}

$error = @mkdir($directory, 0777, true) ? null : ($error ?? $directory.' does not exist and could not be created: '.(error_get_last()['message'] ?? ''));
if (null !== $error) {
throw new \RuntimeException($error);
}
}
}
Expand Down

0 comments on commit 2c2d0f4

Please sign in to comment.