Browse Source

Add a COMPOSER_BINARY env var so that chdir does not affect @composer script resolvability, fixes #6080

Jordi Boggiano 8 years ago
parent
commit
e4840ee413
2 changed files with 3 additions and 1 deletions
  1. 2 0
      bin/composer
  2. 1 1
      src/Composer/EventDispatcher/EventDispatcher.php

+ 2 - 0
bin/composer

@@ -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);

+ 1 - 1
src/Composer/EventDispatcher/EventDispatcher.php

@@ -180,7 +180,7 @@ class EventDispatcher
                     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()));