Upgrading to Cake 5 (out of memory)


I am trying to upgrade from cake 4 to 5. I installed the upgrade tool as per guide.

After sending the command, an error appears. I tried to increase the php-fpm memory_limit to 1024M, but error still persist. Any ideas on how to solve this ?

ubuntu@ip-172-31-10-17:/var/www/upgrade$ sudo bin/cake upgrade rector -v --dry-run --rules cakephp50 /var/www/html/giat/
Detecting autoload file for /var/www/html/giat
-> Checking /var/www/html/giat/vendor/autoload.php
-> Found /var/www/html/giat/vendor/autoload.php
Running /var/www/upgrade/vendor/bin/rector process --dry-run --autoload-file='/var/www/html/giat/vendor/autoload.php' --config='/var/www/upgrade/config/rector/cakephp50.php' '/var/www/html/giat' --clear-cache

  140/7442 [β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘]   1%
 [ERROR] Could not process some files, due to:

         "Child process error: Killed

 [ERROR] Could not process some files, due to:
         "Child process error: Killed

Rector applied successfully

Logs shows :

Nov  3 17:26:07 ip-172-31-10-17 kernel: [ 8743.512339] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=user.slice,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-1.scope,task=php8.1,pid=35195,uid=0
Nov  3 17:26:07 ip-172-31-10-17 kernel: [ 8743.512352] Out of memory: Killed process 35195 (php8.1) total-vm:808308kB, anon-rss:234752kB, file-rss:2068kB, shmem-rss:0kB, UID:0 pgtables:1568kB oom_score_adj:0
Nov  3 17:26:07 ip-172-31-10-17 systemd[1]: session-1.scope: A process of this unit has been killed by the OOM killer.

The PHP FPM Memory limit is not what you need here. You are executing a PHP CLI script.

But the problem with OOM (Out of memor) issues is more of a β€œyou don’t have enough RAM at all in your system”.

Maybe instead of trying to do the ugprade directly on your server try to do it on your local machine which maybe has more RAM available?

Thanks. After increasing the RAM to 16GB (which was still fully utilized by rector/php), it managed to show some other errors.

I am facing the 120s timeout, and based on this site, it says to disable the parallel.


Where can I find the configs for it ? I searched the upgrade-config folder but can’t find it.

I just noticed… You are specifying the wrong folder path.

As the docs say it needs to be the src directory of your app/plugin, NOT the root folder where plugins, vendor etc. is also located at.

This of course will create a massive amount of load because it would try to refactor the vendor folder as well.

So do

sudo bin/cake upgrade rector -v --dry-run --rules cakephp50 /var/www/html/giat/src

instead of

sudo bin/cake upgrade rector -v --dry-run --rules cakephp50 /var/www/html/giat/

Thanks for pointing that out. Now, i am able to process ~80 files (in src) with just 1.5gb of ram. Took a few minutes. Here is the dry-run output (just for anyone curious)

bin/cake upgrade rector -v --dry-run --rules cakephp45  /var/www/html/c5giat/src/
Detecting autoload file for /var/www/html/c5giat/src
-> Checking /var/www/html/c5giat/src/vendor/autoload.php
-> Checking /var/www/html/c5giat/vendor/autoload.php
-> Found /var/www/html/c5giat/vendor/autoload.php
Running /var/www/upgrade/vendor/bin/rector process --dry-run --autoload-file='/var/www/html/c5giat/vendor/autoload.php' --config='/var/www/upgrade/config/rector/cakephp45.php' '/var/www/html/c5giat/src' --clear-cache

 83/83 [β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“] 100%

 [OK] Rector is done!

Rector applied successfully


When I did the rector for cakephp50, there was a lot of differences.
Is there a way to output the rector-differences to a file ?

just pipe the output of that command into a file (a feature of the terminal/Unix, not the upgrade tool)

bin/cake upgrade rector -v --rules cakephp45 /var/www/html/c5giat/src/ > output.log
1 Like