-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
On Windows platforms where projects are deployed on junctions/symlinks, symfony/runtime's ComposerPlugin writes bad $projectDir #49041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you up for sending a PR with your solution? |
@nerdgod PRs should be sent in the monorepo where development happens, not in the subtree split. |
…mlinks (nerdgod) This PR was submitted for the 6.0 branch but it was merged into the 5.4 branch instead. Discussion ---------- Fix for Windows when projects are deployed on junctions/symlinks | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #49041 | License | MIT | Doc PR | none On windows systems where a project directory may be located at a directory that is a junction to a path on another drive, realpath() must be called on both sides of a call to `Filesystem::makePathRelative($path1,$path2)`. Otherwise the result will be an irresolvable comparison across filesystems and the return value will be the value of $path1, not a relative path. Commits ------- 6bbc46c Update ComposerPlugin.php
For those that are struggling with this exact problem while running a Symfony < 5.4.19 (which fixed the issue), I had to try and research for 2 hours but this is the temporary solution I came up with: (Symfony 5.4.4)
This is because even if I set
I hope this helps someone, expecially myself from the future in case I encounter this problem again. And thanks for finding this issue and solving it, so at least I got confirmation that it was a bug and not just a problem in my system configuration. Took me a while to figure it all out, but anyway. |
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, butrealpath(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 ofC:\www\fooProject\\D:\some-storage-directory\www\fooProj
in yourvendor/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
Possible Solution
Call
realpath()
when retrieving both the vendor-dir property and the the composer.json file.Additional Context
No response
The text was updated successfully, but these errors were encountered: