Skip to content

[FileSystem] verbose error when failing to create symlink in windows due to no administrator-rights #4577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public function rename($origin, $target)
* @param string $originDir The origin directory path
* @param string $targetDir The symbolic link name
* @param Boolean $copyOnWindows Whether to copy files if on Windows
*
* @throws \RuntimeException When creation of symlink raises an error that should not be suppressed
*/
public function symlink($originDir, $targetDir, $copyOnWindows = false)
{
Expand All @@ -169,7 +171,15 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
}

if (!$ok) {
symlink($originDir, $targetDir);
if (false === @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (is_array($report) && $report['type'] & error_reporting()) {
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== strpos($report['message'], 'error code(1314)')) {
throw new \RuntimeException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?');
}
throw new \RuntimeException(sprintf("%s in %s line %s", $report['message'], $report['file'], $report['line']));
}
}
}
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy