I am in the process of upgrading a site from CakePHP 3.10.0 to CakePHP 4.x using the 4.x Upgrade Guide. I have been successful up until the point where you need to run the following commands:
bin/cake upgrade rector --rules phpunit80 <path/to/app/tests>
bin/cake upgrade rector --rules cakephp40 <path/to/app/src>
I skipped the first command as I do not do unit testing (yet!). When I run the second command, it just hangs. There is no output at all from this command. I have let it sit for hours but it does nothing. I added -v
to the command and finally got some output but it still hangs:
$ bin/cake upgrade rector --rules cakephp40 ../vintage-lib/src -v
Detecting autoload file for /mnt/d/Programming/PHP/vintage-lib/src
-> Checking /mnt/d/Programming/PHP/vintage-lib/src/vendor/autoload.php
-> Checking /mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php
-> Found /mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php
Running /mnt/d/Programming/PHP/upgrade/vendor/bin/rector process --autoload-file='/mnt/d/Programming/PHP/vintage-lib/vendor/autoload.php' --config='/mnt/d/Programming/PHP/upgrade/config/rector/cakephp40.php' --working-dir='/mnt/d/Programming/PHP/vintage-lib/src' '/mnt/d/Programming/PHP/vintage-lib/src'
I have tried running this in Windows, WSL and even in a Linux VM - the result remains the same which makes me believe it is something with my code or a config file. I tried to run the command on each of my plugins but I get the same result.
I have also run and fixed all errors and warnings from codesniffer but it makes no difference.
I am at a loss as I don't know where to check next. Any assistance would be greatly appreciated.
I undertook an upgrade from 3.4 to 4.0 following the migration guide to a T, going through each minor upgrade and I still had the same issue with rector hanging.
Solution was, there is an Out of the Box PagesController that has been changed at some point between 3.4 and 3.10. I had to replace it with the version from the skeleton app (https://github.com/cakephp/app/blob/3.x/src/Controller/PagesController.php) in order for rector to pass.
If that's not your problem, try running rector one directory at a time to identify the problematic file. You can find the directory listing like: $ find /path/to/app/src/ -type d