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

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