How to fix the «There are no commands defined» failure while executing a console command

setup:upgrade
command-line

(Dmitry Fedyuk) #1

[2017-11-15] Struggling with this problem? Order my resolution service!


In my case the source of the problem was absense of an extension’s etc/module.xml file.

A similar problem: «An abstract factory could not create an instance of».


There are no commands defined in the "indexer" namespace
The «There are no commands defined» / «An abstract factory could not create an instance of» resolution service
Please install the Stripe extension to earosacoustic.com
«An abstract factory could not create an instance of ...command»
(Dmitry Fedyuk) #2

Another cause of the There are no commands defined message could be an error in etc/module.xml file.
For example, if you made a mistake in the module’s name and write

<module name='TwitterTimeline' setup_version='2.0.0'/>

instead of

<module name='Dfe_TwitterTimeline' setup_version='2.0.0'/>

it will lead to the same There are no commands defined error.


(Dmitry Fedyuk) #3

See also:

  • All There are no commands defined issues in the tracker.
  • All There are no commands defined questions on magento.stackexchange.com.

(Sandeep Pandey) #4

thanks dmitry!!! it helped me lot.


(Sandeep Pandey) #5

It not working for me, when i am trying to run indexer like
php bin/magento indexer:reindex

then its shows

[InvalidArgumentException]
There are no commands defined in the “indexer” namespace.

and also tried
sudo php bin/magento indexer:reindex

Then its shows
Content-type: text/html; charset=UTF-8
bin/magento must be run as a CLI application


(Dmitry Fedyuk) #6

You can remove your extensions one-by-one to detect which your extension is wrong.


(Dmitry Fedyuk) #7

I recommend to set a breakpoint here:

As you can see, the exception’s message is «The file “/composer.json” doesn’t exist» in my case.

You can also set breakpoints here:
github.com/magento/magento2/issues/2300#issuecomment-154966006


«An abstract factory could not create an instance of ...command»
(Hung) #8

I have been faced with same issue. Your solution helped. Thank you for sharing!


(Dmitry Fedyuk) #9

Today I have fixed a similar issue in the mage2pro/core package with Magento Marketplace: