Magento – There are no commands defined in the “setup” namespace : Magento 2

clicode generationerrormagento2

I have installed the latest version of Magento 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:

enter image description here

Is there anything I missed during installation or I need to install some package to let it work?

Best Answer

In my case, it worked using sudo

sudo bin/magento setup:upgrade

EDIT 19/02/16

Actually, the "sudo" solution is more a workaround for bad permissions/ownership of Magento files.

If you don't already have a Magento file system owner, create one and add it to the apache group.

adduser magento
passwd magento
    //CentOS
    usermod -g apache magento

    //Ubuntu
    usermod -g www-data magento

//restart apache
    //CentOS
    service httpd restart

    //Ubuntu
    service apache2 restart

Now that you have your user, you can set the ownership and permissions (with root or an user with sudo)

cd /var/www/html/magento2beta/magento2
find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod +x bin/magento
//CentOS
chown -R magento:apache .
//Ubuntu
chown -R magento:www-data .

Switch to the magento user

su magento

Now you should be able to run php bin/magento setup:upgrade or any other command with your magento user

Related Topic