function Application::hintCommonErrors
1 call to Application::hintCommonErrors()
- Application::doRun in vendor/
composer/ composer/ src/ Composer/ Console/ Application.php - Runs the current application.
File
-
vendor/
composer/ composer/ src/ Composer/ Console/ Application.php, line 468
Class
- Application
- The console application that handles the commands
Namespace
Composer\ConsoleCode
private function hintCommonErrors(\Throwable $exception, OutputInterface $output) : void {
$io = $this->getIO();
if ((get_class($exception) === LogicException::class || $exception instanceof \Error) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
Silencer::suppress();
try {
$composer = $this->getComposer(false, true);
if (null !== $composer && function_exists('disk_free_space')) {
$config = $composer->getConfig();
$minSpaceFree = 100 * 1024 * 1024;
if (($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree || ($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree || ($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree) {
$io->writeError('<error>The disk hosting ' . $dir . ' has less than 100MiB of free space, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
}
}
} catch (\Exception $e) {
}
Silencer::restore();
if ($exception instanceof TransportException && str_contains($exception->getMessage(), 'Unable to use a proxy')) {
$io->writeError('<error>The following exception indicates your proxy is misconfigured</error>', true, IOInterface::QUIET);
$io->writeError('<error>Check https://getcomposer.org/doc/faqs/how-to-use-composer-behind-a-proxy.md for details</error>', true, IOInterface::QUIET);
}
if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
$io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
$io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>', true, IOInterface::QUIET);
}
if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
$io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
$io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
}
if ($exception instanceof ProcessTimedOutException) {
$io->writeError('<error>The following exception is caused by a process timeout</error>', true, IOInterface::QUIET);
$io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
}
if ($this->getDisablePluginsByDefault() && $this->isRunningAsRoot() && !$this->io
->isInteractive()) {
$io->writeError('<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the following exception. See also https://getcomposer.org/root</error>', true, IOInterface::QUIET);
}
elseif ($exception instanceof CommandNotFoundException && $this->getDisablePluginsByDefault()) {
$io->writeError('<error>Plugins have been disabled, which may be why some commands are missing, unless you made a typo</error>', true, IOInterface::QUIET);
}
$hints = HttpDownloader::getExceptionHints($exception);
if (null !== $hints && count($hints) > 0) {
foreach ($hints as $hint) {
$io->writeError($hint, true, IOInterface::QUIET);
}
}
}