There are no commands defined in the "setup" namespace : Magento 2
Solution 1
Please mention setup_version
in your module.xml file.
Your module.xml file looks like:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0"/>
</config>
You need to give full permission to both var and pub folders recursively.
sudo chmod -R 777 var pub
Solution 2
Giving full control (read/write/execute) to var and pub directory should solve this issue.
sudo chmod -R 777 var pub
You may also try running the command using sudo.
sudo php bin/magento setup:upgrade
Solution 3
I wanted to add an answer because the others doens't cover all the problems that could generate this error :
There are no commands defined in the "setup" namespace.
in general.
This error could be caused by permission as said in others answer but we could have other scenario.
- The absense of : etc/module.xml
- An error in /etc/module.xml or in /etc/di.xml or others xml extensions under /etc
If you know other scenario please comment this answer.
Hope this help.
Deepak Mankotia
India-based full-stack developer. Currently working with : - #react | #redux | #relay | #grapql | #php | #.net-core | #python #angular | #javascript Exploring : #AI | #ML | #Blockchain Organizer GraphQLCHD : Twitter | Slack | LinkedIN | TownScript Feel free to contact me at [email protected] My Blogs - what is closure in javascript, advantages and disadvantages? | What is event loop in javascript? | Understanding React Hooks | enter link description here If you find something wrong in one of my posts, feel free to edit it. I'm a frequent visitor and can always roll back if I think a change you've made is wrong or stupid, so you may as well be bold - it's better, here, to ask for forgiveness than permission.
Updated on December 10, 2021Comments
-
Deepak Mankotia over 2 years
I have installed
latest version of Megento 2
, everything is working fine frontend, backend and functionality.I have one issue with
bin/magento setup:upgrade
command, when I run this command in terminal I get below exception .[InvalidArgumentException]
There are no commands defined in the "setup" namespace.Screenshot :
Is there any thing I missed during installation or I need to install some package to let it working?
-
alok over 7 yearssudo php bin/magento setup:upgrade is working fine for me.
-
Corgalore almost 6 yearsIn my case I was missing the entire etc/module.xml file when I got that error. Adding the file allowed the command to run correctly.
-
user2239352 over 5 yearsBetween composer create-project and bin/magento setup:install there is only a restricted set of available commands. After install is done, all commands are in place. I don't know yet why this is happening (maybe because there is no database or config file for cache yet..), as all the modules in vendor (which imlements the commands) are present. For example there is no config:set (which i need to run before setup:install), also no cache namespace, no indexing, etc.