-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: composer update
might cause error "Failed to open directory"
#6833
Conversation
Wouldn't it be better to leave it as an exception since this is an exceptional situation? Should we throw an appropriate exception? |
It looks like |
If the recursiveDelete fails with the exception, the recursiveMirror is not executed and the It's better to not throw an Exception, to let the recursiveMirror do the job and correctly finish the update. |
I would agree with @LeMyst, here. The proposed change does not alter the behaviour of the method, but rather provides an early exit to skip the unnecessary generation of Iterator objects if the folder does not exist. |
@LeMyst Please don't use |
I saw that after my action. I will clean my branch tomorrow. |
Yes, if the script is terminated by some reasons right after |
composer update
might cause error "Failed to open directory"
It's cleaned |
How about this? @@ -126,7 +128,11 @@ final class ComposerScripts
exit(1);
}
- @mkdir($targetDir, 0755, true);
+ if (! @mkdir($targetDir, 0755, true)) {
+ echo sprintf('Cannot create the target directory: "%s"' . PHP_EOL, $targetDir);
+
+ exit(1);
+ }
$dirLen = strlen($originDir);
|
Does I need to put this change (who's good for me) into this PR? |
Without the above code, |
Co-authored-by: kenjis <[email protected]>
Co-Authored-By: kenjis <[email protected]>
It's added to the PR, but that raise a question about consistency for the PHP_EOL. Inside or outside the sprintf()? |
Thank you. And good point. |
I would add that to the format string, because it's supposed to be part of the message. |
Another question I've, it's the difference between If I do a I think a hook EDIT: And the comment in
|
No. The third party libraries are updated only when you run |
Co-authored-by: kenjis <[email protected]>
It seems there is different behavior:
You have more informations about this here: https://getcomposer.org/doc/articles/scripts.md#command-events
So I think a hook on post-install-cmd is necessary to copy the ThirdParty libraries. |
Why? |
If you add dependencies to your composer.json/composer.local.json and you push the composer.lock to your version control. When you update the vendor folder with |
Correct me if I'm wrong but... if we're using Composer then we don't even need to update ThirdParty because the Composer sources will be used. |
To be honest, I think if you are using manual install then you don't need ComposerScripts and the post update hook altogether. It's kinda weird you download the zip manually then use Composer to update. I mean, why not use composer initially? |
I don't understand why this is in place, I did not test to remove the ThirdParty folder when you have an up-to-date vendor folder.
I am probably not the best example. I build my project around CodeIgniter. I download the zip file and start my project from this, adding (or not) my dependencies to the composer.local.json, etc. |
@LeMyst Sorry, if you downloaded the Zip file from this If you use Zip installation, you need to replace But If you installed the package with Composer, the Composer package will be autoloaded by CI4's autoloader. If you use Composer, we recommend you don't use Zip installation. I recommend you move to Adding CodeIgniter4 to an Existing Project. Then you can update The |
OK, I will do this next time. Maybe remove the Otherwise, I think we can close this PR if the issue #6832 is solved? |
If devs want to write PHPUnit tests, they need We actually recommend Composer installation. @codeigniter4/core-team
|
Fixes #6832
Description
Exit the function recursiveDelete() if the folder to delete didn't exist.
Fixes #6832
Checklist: