diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index 61ae44f82..cafad5a28 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -162,11 +162,11 @@ class Cache unlink($tempFileName); $message = sprintf( - 'Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available', + 'Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$s bytes of free space available', $tempFileName, $m[1], $m[2], - @disk_free_space(dirname($tempFileName)) + function_exists('disk_free_space') ? @disk_free_space(dirname($tempFileName)) : 'unknown' ); $this->io->writeError($message); diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 242c58154..6e56f3a4f 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -370,6 +370,10 @@ EOT */ private function checkDiskSpace(Config $config) { + if (!function_exists('disk_free_space')) { + return true; + } + $minSpaceFree = 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) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index e7c3a32a5..86e89e88b 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -386,7 +386,7 @@ class Application extends BaseApplication Silencer::suppress(); try { $composer = $this->getComposer(false, true); - if ($composer) { + if (null !== $composer && function_exists('disk_free_space')) { $config = $composer->getConfig(); $minSpaceFree = 1024 * 1024;