[InvalidArgumentException] There are no commands defined in the "cache" namespace.
I am using putty to run some commands. if I run php bin/magento setup:cache Is there any thing I missed during installation
[InvalidArgumentException] There are no commands defined in the "cache" namespace.
I am using putty to run some commands. if I run php bin/magento setup:cache Is there any thing I missed during installation
Please run below commands
rm -Rf var/cache/* generated/*
then
php -f bin/magento cache:flush
php bin/magento indexer:reindex
Solution 1:
The general main cause of this kind of error is missing etc/module.xml
file in your module. Or, missing setup_version
code inmodule.xml
file.
Here is a sample module.xml
file of a module named YourNamespace_YourModule
.
app/code/YourNamespace/YourModule/etc/module.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Moddule/etc/module.xsd">
<module name="Namespace_Yourmodule" setup_version="1.5.0">
</module>
If you are not sure which module is creating this problem, you can try removing each module and check to find the problematic module.
Solution 2:
If solution 1 doesn’t help then you can try this second solution.
Give full control (read/write/execute) to var and pub directory solved this issue for me.
sudo chmod -R 777 var pub
You may also try running the following command:
sudo php -f bin/magento module:enable --clear-static-content YourNamespace_YourModule
First, make sure that the module.xml file is defined properly in the etc directory of your module.
Then, run these commands in the root directory
rm -rf var/di/* var/generation/* var/cache/* var/page_cache/* pub/static/*
php bim/magento cache:clean
php bim/magento cache:flush
edit:
php bin/magento cache:clean
php bin/magento cache:flush
Seems some modules without file etc/module.xml
and this create error in command line
This also happens to me sometimes in sandbox env due to a wrong server configuration and not a code issue as mentionned in the others responses.
When this happens if it's not a code issue, I run composer install
to properly reinstall magento and after that the command CLI works again as expected.
No solution worked for me, removed var/* generated/* but one solution worked, that is i reinstall magento using cmd. and it fixed all the issues. hope this help for fresh installion