Skip to content

Commit

Permalink
Add a COMPOSER_BINARY env var so that chdir does not affect @composer
Browse files Browse the repository at this point in the history
…script resolvability, fixes #6080
  • Loading branch information
Seldaek committed Jan 22, 2017
1 parent 0ea93df commit e4840ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bin/composer
Expand Up @@ -48,6 +48,8 @@ if (function_exists('ini_set')) {
unset($memoryInBytes, $memoryLimit);
}

putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));

// run the command application
$application = new Application();
$application->run(null, $output);
2 changes: 1 addition & 1 deletion src/Composer/EventDispatcher/EventDispatcher.php
Expand Up @@ -180,7 +180,7 @@ protected function doDispatch(Event $event)
if (!$phpPath) {
throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName);
}
$exec = $phpPath . ' ' . realpath($_SERVER['argv'][0]) . substr($callable, 9);
$exec = ProcessExecutor::escape($phpPath) . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
if (0 !== ($exitCode = $this->process->execute($exec))) {
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()));

Expand Down

0 comments on commit e4840ee

Please sign in to comment.