0

[InvalidArgumentException] There are no commands defined in the "cache" namespace. enter image description here

I am using putty to run some commands. if I run php bin/magento setup:cache Is there any thing I missed during installation

6
  • which command you are trying ?
    – Pawan
    Oct 5, 2018 at 1:46
  • Php bin/magento cache:flush
    – kiran
    Oct 5, 2018 at 2:05
  • I uploaded all files on server then I run upgrade and cache flush commands using putty. it showing me above error.
    – kiran
    Oct 5, 2018 at 2:07
  • once check with php bin/magento list, Is it showing all commands ?
    – Pawan
    Oct 5, 2018 at 2:14
  • go through this link
    – Hitesh
    Oct 5, 2018 at 4:29

6 Answers 6

1

Please run below commands

rm -Rf var/cache/* generated/*

then

php -f bin/magento cache:flush

php bin/magento indexer:reindex
1

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

1

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

1
  • Please update your answer, it is bin not bim Oct 1, 2020 at 11:15
0

Seems some modules without file etc/module.xml

and this create error in command line

0

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.

  • Sending a magento command in CLI
  • Getting the no command defined error as a result for an unknown reason.

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.

0

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

1
  • that's what composer install does though :)
    – Claims
    Jan 21, 2022 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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