33

I have a problem when I run this command:

php bin/magento setup:upgrade

Display error:

[InvalidArgumentException]
There are no commands defined in the "setup" namespace.

I found some answers but not in my case(I run in Windows 7 and Xampp).
There are no commands defined in the “setup” namespace : Magento 2

On frontend display:
enter image description here Last time, I fixed is the system my pool code have errors with my module. And now I remove all my modules but error until display. Anyone used to fix this problem, Can you tell me how to fix this problem?

When I run the command to install again composer, it returns error below:
enter image description here

1
  • 1
    check extensions, maybe missing module.xml file
    – Alex
    Feb 1, 2019 at 13:20

4 Answers 4

109

Run this command:

php bin/magento list

When everything is working correctly, this should list out all of the possible commands in your Magento 2 command line interface. However, in the event that something is going wrong, this will also give you a much more descriptive error message about how and why it is failing.

This could be the result of an invalid composer.json module file, among other things.

See also: https://magento.stackexchange.com/a/91696/1905

6
  • Thanks @Ryan. I tried many other answers, but yours helped me only. Sep 1, 2016 at 5:05
  • Thanks, for me it thrown even error in list command but later i realized there is folder right problem
    – AbdulBasit
    Oct 11, 2017 at 13:01
  • 2
    Great answer because it gives a more detailed error message. Was able to track down the issue after running this command.
    – Cypher909
    Oct 10, 2019 at 15:21
  • thanks it was helpful it showed some error instead of nothingness Jan 21, 2020 at 15:12
  • Thanks @Ryan above command helped us to identify the issue which went wrong
    – Ishak Ali
    Oct 27, 2020 at 14:25
35

Also happens when the module name in module.xml does not match with path based namespace. Please check your module name again: code/Vendor/myModuleName/etc/module.xml

We can read more here: https://gist.github.com/bka/d44fb33d1eaf780e1b76

1
3

I had the same issue and I followed several suggested stupid suggestions to fix the problem like delete my composer.json something like that. But those didn't fix my problem. Today, I faced the problem again and I tried a new approach to trace the problem. All details and screenshot are in my personal blog post http://david.firstbiz.cc/blog_detail.php?id=115 I described my steps here:

1. for CLI, please append "-vvv" and it will display function trace paths
2. try to load any product page and check your web server error log and you will be able to see more details.
3. the class name and the filename should be same (*this is the case I faced)
1
  • You blog is not reachable
    – Black
    Jan 31, 2020 at 10:35
0

If anyone have dependencies (especially coming from custom modules) in you CLI class, you have to check all of the class for possible problems. If somewhere you are playing around with RequestInterface it can cause problem - but don't know why.

Not the answer you're looking for? Browse other questions tagged or ask your own question.