From abcf9e993bb2787a1ce59154a406341eb33d379f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 11 Feb 2021 12:43:43 +0100 Subject: [PATCH] Fix processes silently ignoring the CWD when it does not exist, refs #9694 --- src/Composer/Repository/Vcs/GitDriver.php | 3 +++ src/Composer/Util/ProcessExecutor.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 8c6902298557..2c7782c98fff 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -38,6 +38,9 @@ public function initialize() { if (Filesystem::isLocalPath($this->url)) { $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url); + if (!is_dir($this->url)) { + throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist'); + } $this->repoDir = $this->url; $cacheUrl = realpath($this->url); } else { diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 83f19cf2d033..cb935e0eb239 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -61,6 +61,10 @@ public function execute($command, &$output = null, $cwd = null) $cwd = realpath(getcwd()); } + if (null !== $cwd && !is_dir($cwd)) { + throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd); + } + $this->captureOutput = func_num_args() > 1; $this->errorOutput = null;