Description
Symfony version(s) affected
6.0+
Description
On Windows platforms, if the project is placed in a junction or symlink on another drive than the directory the commands are run from, then, symfony/runtime/Internal/ComposerPlugin.php' $this->composer->getConfig()->get('vendor-dir')
returns the junction path, but realpath(Factory::getComposerFile())
returns the junction target path.
So if your project is at C:\www\fooProject ->{junction-to}-> D:\some-storage-directory\www\fooProj, the call to $fs->makePathRelative()
tries to make relative paths across filesystems and you end up with a project directory of C:\www\fooProject\\D:\some-storage-directory\www\fooProj
in your vendor/autoload_runtime.php
.
How to reproduce
Create a project on a windows system having two separate drives.
In another directory use mklink /D <projname> <orig_proj_path>
e.g.: project is in Z:\Projects\foo (the 'source') but it is linked to C:\Users\fabien\Desktop\foo (the 'link')
change directory to the link.
remove the vendor dir and re-run composer update
run any composer scripts (auto-scripts or cache:clear)
the script fails with an error because the C:\Users\fabien\Desktop\foo\vendor/autoload_runtime.php has something like
$runtime = new $runtime(($_SERVER['APP_RUNTIME_OPTIONS'] ?? $_ENV['APP_RUNTIME_OPTIONS'] ?? []) + [
'project_dir' => __DIR__.'/Z:/Projects/foo/',
]);
Possible Solution
Call realpath()
when retrieving both the vendor-dir property and the the composer.json file.
Additional Context
No response