-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Content of junction directories gets deleted after running composer update #4955
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
Please know I take this issue very seriously as it's my code and I feared it may have such consequences, as PHP does not provide any kind of API to reliably detect junctions itself. We did a few doublechecks before releasing, ie. #4690 (comment). I will try to reproduce and fix your issue when I have time. I may need a Skype or IRC chat to reproduce your case if you don't mind that. |
Thinking some more and I suspect this is a nasty fringe case where a recursive delete is still used when purging packages, while updates and regular removes detect the junction correctly. As the Symfony filesystem class is oblivious of junctions, and NTFS junctions are close to undetectable anyway, a recursive delete does not notice the junction at all and just continues deleting files inside the linked folder. Thankfully this means it shouldn't be too hard to fix. |
@curry684 seeing as we only use junctions in PathDownloader, it might be worth implementing PathDownloader::remove() and just doing a removeJunction always in there if we're on windows. I mean always attempt removing the junction using the proper command, and if that fails then run a regular remove? However from what I can tell in Util\Filesystem, removeJunction basically just runs the same command as remove. So the only case I can see where it'd fail is if proc_open() isn't defined, but if that was the case the junction couldn't have been created either. It's all quite odd. |
Just tried to reproduce this and no luck at all - several install/uninstall cycles each correctly detected and removed the junction. We implemented it at the right level, as So the only thing that can go wrong is either @hediet which exact Windows version are you using? And can you run the following PHP snippet on the
I'm very interested in the output. |
I totally forget to include my system configuration, sorry for that:
It is new to me that I noticed that the actual behavior is slightly different from what I described earlier:
And the lib directory now is gone too. |
the fact that removing it failed might be why the content was deleted though. It may totally be related. |
That is really weird, this seems to indicate PHP is thinking it's a true folder.
It could most certainly cause scary behavior as a lot of the (un)install logic in Composer core falls back to recursive delete if cleaner methods fail. So yes, this would most certainly explain some weirdo behaviors. I'll look into shortwiring that completely to Windows-native commands to prevent all of that from ever possibly happening. |
Attached PR should fix this issue, thanks a lot for helping out with the TeamViewer 👍 |
I have just been affected by this issue and had all my new library code gone before I even pushed to github. This is pretty frustrating... Wondering why the issue is closed? |
Because the issue was fixed and confirmed to be fixed on Feb 25 2016, and hasn't been heard of in the 2.5 years since. Please open a new issue describing your problems if you have run into something similar. |
This still happens and as requested I have opened a new issue (#9583) with a detailed analysis of what happens. (No conclusion though.) |
In my scenario there are two composer projects: "lib" and "main". "main" has a dependency to "lib".
As I am developing both projects simultaneously I used the path type repository feature that instructs composer to create a junction directory rather than downloading the "lib" project from packagist.org.
However, when I now remove the dependency from "main" to "lib" and run
composer update
in the "main" directory, composer deletes the whole content of the "lib" directory instead of just removing the junction directory. This almost led to a devastating loss of really much work...Steps to reproduce
This is the
composer.json
file of the lib project in the directory "lib":And of the main project in the directory "main":
After running
composer update
in both the lib and the main directory, I removed the dependency from main to lib. Then I rancomposer update
again.Expected result
The vendor directory in the main directory is empty, the original lib directory including any files in it are not touched by the composer updates.
Actual result
The vendor directory in the main directory is empty and the lib directory on root level is now empty too. All files (and subdirectories) of the lib directory were deleted with the last
composer update
.The text was updated successfully, but these errors were encountered: