Search code examples
phpshellcakephpcakephp-bake

Cannot use 'Bake\Shell\CommonOptionsTrait' for command 'common_options_trait' it is not a subclass of Cake\Console\Shell


I have installed cakephp 3.5 via composer and tried to setup a migration file using cake bake. But got following error:

Cannot use 'Bake\Shell\CommonOptionsTrait' for command 'common_options_trait' it is not a subclass of Cake\Console\Shell. in [C:\xampp\htdocs\myproject\vendor\cakephp\cakephp\src\Console\CommandCollection.php, line 65]

Everything seems to be working fine including the default cakephp home page, except bake. I have checked if tmp and logs folder are writable or not, found that they are writable. I just can't figure out what is causing this exception??

Following details might help:-

1) CakePHP 3.5.3

2) PHP 7.0.21

One more thing, whenever i call bake command. It creates error log named "cli-error.log" under logs folder. Here is what it logged in it:-

2017-10-15 17:57:57 Error: [InvalidArgumentException] Cannot use 'Bake\Shell\CommonOptionsTrait' for command 'common_options_trait' it is not a subclass of Cake\Console\Shell. in C:\xampp\htdocs\hellocake\vendor\cakephp\cakephp\src\Console\CommandCollection.php on line 65

Stack Trace:

 #0 C:\xampp\htdocs\hellocake\vendor\cakephp\cakephp\src\Console\CommandCollection.php(85): Cake\Console\CommandCollection->add('common_options_...', 'Bake\\Shell\\Comm...')
 #1 C:\xampp\htdocs\hellocake\vendor\cakephp\cakephp\src\Http\BaseApplication.php(86): Cake\Console\CommandCollection->addMany(Array)
 #2 C:\xampp\htdocs\hellocake\vendor\cakephp\cakephp\src\Console\CommandRunner.php(120): Cake\Http\BaseApplication->console(Object(Cake\Console\CommandCollection))
 #3 C:\xampp\htdocs\hellocake\bin\cake.php(12): Cake\Console\CommandRunner->run(Array)
 #4 {main}

Please help.


Solution

  • That's a bug that has recently been fixed:

    https://github.com/cakephp/cakephp/issues/11326

    Make sure to update your apps cakephp/bake dependency (a simple composer update should do it) so that you have the lastest 1.4.4 installed, where the problem should be fixed.