From f57e272ce7a88d4131bb0292d7142390b1541032 Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:02:05 +0300 Subject: [PATCH 1/7] Add a little more explaining message when failing to download. --- src/Composer/Downloader/GitDownloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 76c62033e..520c8fca3 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -93,7 +93,7 @@ class GitDownloader extends VcsDownloader $this->filesystem->removeDirectory($path); } } - throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $this->process->getErrorOutput()); + throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting. Please check your git installation, and its accessibility through the console' . "\n\n" . $this->process->getErrorOutput()); } $command = call_user_func($commandCallable, $url); From bd116aec22df8827380a3ebf3f7a339982ffd484 Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:20:17 +0300 Subject: [PATCH 2/7] try to guess the error --- src/Composer/Downloader/GitDownloader.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 520c8fca3..332ed5f8b 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -93,8 +93,14 @@ class GitDownloader extends VcsDownloader $this->filesystem->removeDirectory($path); } } - throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting. Please check your git installation, and its accessibility through the console' . "\n\n" . $this->process->getErrorOutput()); - } + + // failed to checkout, first check git accessibility + $output = $this->process->getErrorOutput(); + if (false === strpos($this->process->execute('git --version', $handler), 'git version')) { + throw new \RuntimeException('It looks like git isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); + } else { + throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $output); + } $command = call_user_func($commandCallable, $url); if (0 !== $this->process->execute($command, $handler)) { From 2c58dbf3a1f5ef8492d85e38706f5818a6a8b89d Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:21:48 +0300 Subject: [PATCH 3/7] better message if git isn't found --- src/Composer/Repository/Vcs/GitDriver.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index a6750b7a3..4a88ecc31 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -53,7 +53,12 @@ class GitDriver extends VcsDriver $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)); if (0 !== $this->process->execute($command, $output)) { - throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it ('.$this->process->getErrorOutput().')'); + $output = $this->process->getErrorOutput(); + if (false === strpos($this->process->execute('git --version', $handler), 'git version')) { + throw new \RuntimeException('Failed to clone '.$this->url.', it looks like git isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); + } else { + throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it ('.$output.')'); + } } } } From d245acff8371b44046662abb27a9ba7d178d32db Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:26:15 +0300 Subject: [PATCH 4/7] github online editor is a nice idea, but... --- src/Composer/Downloader/GitDownloader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 332ed5f8b..169fffaa8 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -101,6 +101,7 @@ class GitDownloader extends VcsDownloader } else { throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $output); } + } $command = call_user_func($commandCallable, $url); if (0 !== $this->process->execute($command, $handler)) { From 66cd1aad8a5100ead1138c20249451a251d3ec8a Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:30:50 +0300 Subject: [PATCH 5/7] Update src/Composer/Downloader/GitDownloader.php --- src/Composer/Downloader/GitDownloader.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 169fffaa8..09e0e87a8 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -96,11 +96,10 @@ class GitDownloader extends VcsDownloader // failed to checkout, first check git accessibility $output = $this->process->getErrorOutput(); - if (false === strpos($this->process->execute('git --version', $handler), 'git version')) { - throw new \RuntimeException('It looks like git isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); - } else { - throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $output); - } + if (127 === $this->process->execute('git --version', $handler)) { + throw new \RuntimeException('Failed to checkout ' . $url . ' via git, it isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); + + throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $output); } $command = call_user_func($commandCallable, $url); From 66efa343a916416ee08642d12987e2fcb8815a26 Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:35:58 +0300 Subject: [PATCH 6/7] and again. --- src/Composer/Downloader/GitDownloader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 09e0e87a8..ec63cefda 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -98,6 +98,7 @@ class GitDownloader extends VcsDownloader $output = $this->process->getErrorOutput(); if (127 === $this->process->execute('git --version', $handler)) { throw new \RuntimeException('Failed to checkout ' . $url . ' via git, it isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); + } throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $output); } From 1dba604ba12bf627f61dbde30cf4df42637a682c Mon Sep 17 00:00:00 2001 From: Nami-Doc Date: Thu, 5 Apr 2012 18:46:15 +0300 Subject: [PATCH 7/7] Update src/Composer/Repository/Vcs/GitDriver.php --- src/Composer/Repository/Vcs/GitDriver.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 4a88ecc31..645feea4e 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -54,11 +54,12 @@ class GitDriver extends VcsDriver $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)); if (0 !== $this->process->execute($command, $output)) { $output = $this->process->getErrorOutput(); - if (false === strpos($this->process->execute('git --version', $handler), 'git version')) { - throw new \RuntimeException('Failed to clone '.$this->url.', it looks like git isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); - } else { - throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it ('.$output.')'); + + if (127 === $this->process->execute('git --version', $handler)) { + throw new \RuntimeException('Failed to clone '.$this->url.', git isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput()); } + + throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it ('.$output.')'); } } }