-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Junction content still gets deleted after composer update #5053
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
I don't know whats going on.. the problem does not appear when i try it with xdebug.. |
That's really weird, that should have no influence at all. Is it completely reproducable with xdebug disabled? |
Yes. I'm running this with PHP 7.0.4 VC14 x64 TS and Xdebug 2.4.0 for the corresponding php version. |
Is that the exact command you use to run it with xdebug (does it contain all the flags you pass)? |
This error is really weird as well in this context. Have you created a path repository with a glob that matches both the install source and destination, ie. If not, please share a bit more about the specific setup. This error indicates you're doing something really special that we may not have foreseen. |
Didn't even notice that yet, good catch @curry684. However, his real issue should be reproducible with the given two composer.json files and directory structure (for anyone running Windows), as that does not seem to have a conflicting source/install path. |
I removed every single xdebug configuration, so yes, thats the whole command. There is no special repository - I can literally create these two files in a new directory, run |
What the problem is with the junctioning is that the Symfony filesystem components does not know them, and contains a lot of fallback code for when cleanly removing a folder fails, using RecursiveDirectoryIterator instead, obviously cleaning out the source as well as the target. Thus we needed to have some extra patches in place to prevent that from happening at all costs. I'll try reproducing the test case when I have time, I'm running PHP7 on Win10 as well so should be possible. |
I can't reproduce your issue sadly, but I just noticed the true culprit:
This is where it start going wrong, the rest is just symptoms, as it should log explicitly about the junction:
Can you doublecheck that at that point the folder in Explorer shows a little junction arrow? If so please share the output of: php -r "var_dump(is_dir('vendor/test/a'));"
php -r "var_dump(is_link('vendor/test/a'));"
php -r "var_dump(lstat('vendor/test/a'));" edit: I'm also curious whether I suspect PHP has some internal issues with stat caches here, and xdebug is likely disabling those. |
Yes it is definitely still a junction. (Restoring the source content also restores it in the junction.)
Meanwhile I've been checking on my own. If I run composer with xdebug or print anything inside Filesystem::isJunction before the !is_dir | is_link check, lstat mode is 60230 otherweise its 0. |
I meant the other way around sorry.. 60230 if I dont do anything and just check the mode after the lstat, 0 otherwise. |
Hang on, so what you are describing now is that this script: <?php
$path = 'vendor/test/a';
var_dump(lstat($path)['mode']);
var_dump(is_dir($path) && !is_link($path));
var_dump(lstat($path)['mode']);
Is this correct? With my 7.0.2 NTS build I get same output on both: C:\Projects\ComposerTest>php test.php
int(0)
bool(true)
int(0)
C:\Projects\ComposerTest>php -n test.php
int(0)
8000
bool(true)
int(0) php -n disables all configs, so no xdebug, if you want to doublecheck that you can add a |
Nono, I meant composer itself, not that. I still ran the script though, and it's as expected By modifying the source in Filesystem::isJunction i get the following: Except if I run it with xdebug or add e.g. |
I understand what's happening now and will issue a PR shortly. Would appreciate if you could test it. |
You can run self-update and try with latest composer now. |
Yep that works. - Thanks a lot! |
It's a really fubar situation as a whole hehe. The problem is that without xdebug the stat cache is far more aggressive, and in this specific case you are running into the issue that Composer core itself creates a placeholder folder for all packages it wants to install, with PHP's native functions. The junctions however need to be created via ProcessExecutor as PHP has not wrapped them. So at some point during execution Must say I've never liked PHP's stat caches, this just proves they can be an unexpected and unseen source of disaster. Many thanks to you for the detailed reports and thorough testing 👍 |
Yea absolutely confusing.. :P |
To be honest I haven't a clue on that haha. The stat caches are internal magic and the bad part about magic is that it's just as hard to see why it's working as why it's not. |
sounds like magic of a tick-function or error-handler or something |
Could even be output buffering causing file IO that triggers a stat cache overflow causing it to be reloaded correctly. I couldn't reproduce the actual issue once on Win10+PHP7.0.2 NTS, so it could even be that the thread safety is causing it in some freaky interaction with IIS on his computer. |
I thought I might try that and indeed, using PHP NTS without cache clearing would've worked. |
This is similar to #4955, but happens only on consecutive updates, if the dependency composer.json has been updated. All the junction content is gone after this:
Junction lstat is as follows:
And this is the premise: (On Windows 10)
composer update
composer update
The text was updated successfully, but these errors were encountered: