codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.39k stars 1.9k forks source link

`composer update` fails when trying to delete a non-existent folder #6832

Closed LeMyst closed 2 years ago

LeMyst commented 2 years ago

PHP Version

8.1

CodeIgniter4 Version

4.2.10

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

Windows, Linux

Which server did you use?

fpm-fcgi

Database

No response

What happened?

During a composer update, the function "recursiveDelete()" fail because the folder doesn't exist and block the update process.

$ php composer.phar update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
50 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> CodeIgniter\ComposerScripts::postUpdate
Cannot recursively delete "/home/myst/xxxxxxx/system/ThirdParty/" as it does not exist.Script CodeIgniter\ComposerScripts::postUpdate handling the post-update-cmd event terminated with an exception

In ComposerScripts.php line 95:

  RecursiveDirectoryIterator::__construct(/home/myst/xxxxxxx/system/ThirdParty): Failed to open directory: No such file or directory

update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>...]

Steps to Reproduce

Delete the folder "system/ThirdParty" and run the command composer update

Expected Output

Only the Cannot recursively delete "/home/myst/xxxxxxx/system/ThirdParty/" as it does not exist. message without the Exception.

Anything else?

Can be solved by simply add a return; in the if of recursiveDelete().

kenjis commented 2 years ago

If you remove files in system, CI4 won't work.

paulbalandan commented 2 years ago

Why would system/ThirdParty not exist in the first place?

LeMyst commented 2 years ago

Hello @kenjis and @paulbalandan ,

I don't know, but I was in this case.

Maybe a previous recursiveDelete() fails, maybe something else, but I think it's better to not fail the entire update process only because a "delete folder" function can't delete the folder because the folder is already deleted.

kenjis commented 2 years ago

Yes, if the script is terminated by some reasons right after recursiveDelete() execution, system/ThirdParty/ does not exist when the next execution of composer update.

So, the case where system/ThirdParty/ does not exist could happen.