Skip to content

Commit d4396a8

Browse files
committed
Fix binary proxies having an absolute path to vendor dir when project dir is a symlink, fixes composer#11947
1 parent 80631d2 commit d4396a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Composer/Installer/BinaryInstaller.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ protected function generateUnixyProxyCode(string $bin, string $link): string
225225
$phpunitHack1 = $phpunitHack2 = '';
226226
// Don't expose autoload path when vendor dir was not set in custom installers
227227
if ($this->vendorDir) {
228-
$globalsCode .= '$GLOBALS[\'_composer_autoload_path\'] = ' . $this->filesystem->findShortestPathCode($link, $this->vendorDir . '/autoload.php', false, true).";\n";
228+
// ensure comparisons work accurately if the CWD is a symlink, as $link is realpath'd already
229+
$vendorDirReal = realpath($this->vendorDir);
230+
if ($vendorDirReal === false) {
231+
$vendorDirReal = $this->vendorDir;
232+
}
233+
$globalsCode .= '$GLOBALS[\'_composer_autoload_path\'] = ' . $this->filesystem->findShortestPathCode($link, $vendorDirReal . '/autoload.php', false, true).";\n";
229234
}
230235
// Add workaround for PHPUnit process isolation
231236
if ($this->filesystem->normalizePath($bin) === $this->filesystem->normalizePath($this->vendorDir.'/phpunit/phpunit/phpunit')) {

0 commit comments

Comments
 (0)