28

Update

Everything is working now but There are no commands defined in the "cache" namespace is still there. I tried chmod 777 -R var/generation, didn't fix a thing. AFAIK no module is enabled

   public_html]# bin/magento module:status
List of enabled modules:
Nosto_Tagging

List of disabled modules:
Magento_Store
Magento_AdvancedPricingImportExport
Magento_Directory
Magento_Theme
Magento_Backend
Magento_Backup
Magento_Eav
Magento_Customer
Magento_BundleImportExport
Magento_AdminNotification
Magento_CacheInvalidate
Magento_Indexer
Magento_Cms
Magento_CatalogImportExport
Magento_Catalog
Magento_Rule
Magento_Msrp
Magento_Search
Magento_Bundle
Magento_Quote
Magento_CatalogUrlRewrite
Magento_Widget
Magento_SalesSequence
Magento_CheckoutAgreements
Magento_Payment
Magento_Downloadable
Magento_CmsUrlRewrite
Magento_Config
Magento_ConfigurableImportExport
Magento_CatalogInventory
Magento_SampleData
Magento_Contact
Magento_Cookie
Magento_Cron
Magento_CurrencySymbol
Magento_CatalogSearch
Magento_CustomerImportExport
Magento_CustomerSampleData
Magento_Deploy
Magento_Developer
Magento_Dhl
Magento_Authorization
Magento_User
Magento_ImportExport
Magento_Sales
Magento_CatalogRule
Magento_Email
Magento_EncryptionKey
Magento_Fedex
Magento_GiftMessage
Magento_Checkout
Magento_GoogleAnalytics
Magento_GoogleOptimizer
Magento_GroupedImportExport
Magento_GroupedProduct
Magento_Tax
Magento_DownloadableImportExport
Magento_Braintree
Magento_Integration
Magento_LayeredNavigation
Magento_Marketplace
Magento_MediaStorage
Magento_ConfigurableProduct
Magento_MsrpSampleData
Magento_Multishipping
Magento_NewRelicReporting
Magento_Newsletter
Magento_OfflinePayments
Magento_SalesRule
Magento_OfflineShipping
Magento_PageCache
Magento_Captcha
Magento_Paypal
Magento_Persistent
Magento_ProductAlert
Magento_Weee
Magento_ProductVideo
Magento_CatalogSampleData
Magento_Reports
Magento_RequireJs
Magento_Review
Magento_BundleSampleData
Magento_Rss
Magento_DownloadableSampleData
Magento_Authorizenet
Magento_OfflineShippingSampleData
Magento_ConfigurableSampleData
Magento_SalesSampleData
Magento_ProductLinksSampleData
Magento_ThemeSampleData
Magento_ReviewSampleData
Magento_SendFriend
Magento_Ui
Magento_Sitemap
Magento_CatalogRuleConfigurable
Magento_Swagger
Magento_Swatches
Magento_SwatchesSampleData
Magento_GroupedProductSampleData
Magento_TaxImportExport
Magento_TaxSampleData
Magento_GoogleAdwords
Magento_CmsSampleData
Magento_Translation
Magento_Shipping
Magento_Ups
Magento_UrlRewrite
Magento_CatalogRuleSampleData
Magento_Usps
Magento_Variable
Magento_Version
Magento_Webapi
Magento_WebapiSecurity
Magento_SalesRuleSampleData
Magento_CatalogWidget
Magento_WidgetSampleData
Magento_Wishlist
Magento_WishlistSampleData
Sm_BasicProducts
Sm_Categories
Sm_Deals
Sm_ImageSlider
Sm_ListingTabs
Sm_Market
Sm_MegaMenu
Sm_QuickView

The issue was there long before I installed nosto, I initially installed SM quickstart then upgraded it the latest magento version. if I clear the cache from admin area, I see no error. I need to fix it otherwise I'll never be able to install any module or fix this

Update now I disabled nosto.

12
  • if the images are too big, please remove them and just leave a link to imgur instead
    – Lynob
    Jun 23, 2016 at 21:03
  • @ProxiBlue no I havent, will try it this weekend and let u know, thanks for the info, i believe your solution will solve it
    – Lynob
    Jun 27, 2016 at 14:09
  • 1
    I have had this issue, or variations of the same, many times whilst coding my first m2 module. In all instances, it was caused by my own code, usualky some issue in the module.xml. Considering that, i would venture some 3rd part moduke is havibg an issue. May need an update. Figure you will have to systematically disable 3rd party modules to find the culprit(s)
    – ProxiBlue
    Jun 27, 2016 at 14:12
  • Sorry. Accidentalky deleted my comment. So just reposred.
    – ProxiBlue
    Jun 27, 2016 at 14:13
  • @ProxiBlue thats fine and if a module can cause that then the error is definitely caused by a module since i'm using a custom magento version backed by SM market, it has its own theme and a trillion extension i don't know what for, seems i have to disable them 1 by 1
    – Lynob
    Jun 27, 2016 at 14:17

19 Answers 19

42

That error comes up when a module does not correctly declare its commands. It just stops Magento from correctly reading the wole commands list.

Unless you have broken third party modules, you probably have something left in your cache or generation folder preventing you to correctly run Magento commands.

From your Magento root:

rm -Rf var/cache/*
rm -Rf generated/* (or rm -Rf var/generation/* depending on your Magento version)

Then try again:

php bin/magento cache:flush

If it does not work just try to run:

php bin/magento

And see what is the last shown command.

9
  • 3
    no it did not work and heres the output of php bin/magento pastebin.com/AknS0gV9
    – Lynob
    Jun 23, 2016 at 23:48
  • Did you turn on display_errors on CLI? Jun 24, 2016 at 7:31
  • 1
    php -d display_errors bin/magento >log.txt no strage errors
    – Lynob
    Jun 24, 2016 at 8:07
  • should i turn it on from php.ini? should i use magento verbose?
    – Lynob
    Jun 24, 2016 at 8:08
  • Uhm... any 3rd part modules? Jun 27, 2016 at 21:13
17

$ bin/magento module:enable --all

3
  • This command will generate the app/etc/config.php file which contains all installed module and there activation status. Jan 13, 2019 at 16:49
  • Works for me, all my modules where disabled because I installed via git and composer update
    – Black
    May 14, 2020 at 12:49
  • 1
    Why would some one activate all modules? This is terrible. Sep 13, 2021 at 13:44
15

I have gone through the same problem. I have done same as you delete pub/static content but after re-deploying I didn't get the solutions. Again I installed fresh Magento. After some time again I face this issue but this time, I used the best approach. Hope this will work for you : Use the following command from your magento root directory

  1. sudo rm -rf var/di/* var/generation/* var/cache/* var/page_cache/* var/view_preprocessed/* var/composer_home/cache/*

  2. sudo chmod 777 var -R

  3. sudo chmod 777 pub -R

  4. sudo php bin/magento setup:static-content:deploy

    Repeat step 2 & 3.

Please avoid 777 on the production server, but provide read and write permission for Magento.

3
  • Thanks Lynob. Please can you paste your error here ?
    – Manish
    Jun 27, 2016 at 14:16
  • 1
    same error, the steps didn't fix it, i guess some sort of a custom module is causing the issue
    – Lynob
    Jun 27, 2016 at 14:28
  • 1
    Downvoted for 777 as a solution.
    – Vicary
    Nov 21, 2017 at 18:28
13

it got same problem . i have been resolve by run this command :

php bin/magento

after done, it display the errors like as "Circular sequence reference ..." . With this errors,we only remove :

in etc/module.xml, because the module name already defined in module tag.

1
  • same problem as question above... just add module.xml file. +1 your answer give me hint.,
    – Ali Raza
    Oct 8, 2020 at 8:08
3

I had this issue once as well. Mine happened because I was doing a clean refresh

php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento indexer:reindex php bin/magento cache:clean

how I broke mine was I was rushed at work to go home and continue working not completing the steps thinking I could just ssh back into the server and finish. sure enough, I had to clear var/cache/* var/page_cache/* var/di/* var/generation/* and then run the process over again and everything worked fine.

just sharing my experience. hope it helps you in your troubleshooting.

2

Try this,

  • sudo chmod -R 777 var
  • sudo chmod -R 777 pub
  • sudo php bin/magento setup:upgrade
1
  • while this may help giving write permission to anything and everyone is NOT the way to go. Set the permissions correctly so that the correct use can write to these folders.
    – Andy
    Jul 19, 2018 at 8:45
2

Check if any of your newly created module's etc/module.xml file doesn't have any syntax errors.

1
  • Seems like any syntax error in any XML file will cause this error; I got the error from a syntax error in a etc/events.xml
    – Jacques
    Apr 30, 2021 at 9:44
1

2nd answer after you updated your post:

According to your module:status output you have all the Magento core modules disabled. I've never seen this and I do not know how your admin is still working!

Anyway open your app/etc/config.php file and set all the modules starting with Magento_ to 1.

Example:

...
return array (
  'modules' => 
  array (
    ...
    'Magento_Store' => 1,
    'Magento_AdvancedPricingImportExport' => 1,
    'Magento_Directory' => 1,
    ...
...

After this, from you Magento root run:

rm -Rf var/cache/*
rm -Rf var/generation/*

And try again.

1

I struggled with this for a while, not finding any information on these forums, until I finally figured it out. I had a 3rd party module that was not properly defined. I had the registration.php file in place, but I didn't have the etc\module.xml file. Instead of gracefully erroring out or ignoring the mis-configured module, it kills the entire Magento engine, including the CLI. I couldn't even run bin/magento module:status without it throwing the same error.

So, if this happens to you, and all other solutions fail, check that you don't have a misconfigured extension.

1

I got same issue

[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "cache" namespace.

I checked in my source lost file etc/evn.php. Push on source and it be fixed.

1

Check module.xml file of your last installed extension. This error generally because of this file only

0
1

Finally, combining all tips from previous answers cache:flush worked for me:

1. rm -rf generated/code
2. rm -rf var/cache
3. rm -rf var/view_preprocessed
4. php -d memory_limit=-1 /usr/bin/composer install
5. php -d memory_limit=-1 bin/magento

If php -d memory_limit=-1 bin/magento cache:flush still doesn't work then continue...

6. php -d memory_limit=-1 bin/magento module:enable --all 
    #You can disable selected ones later if required.

Now try to run cache flush again.

7. php -d memory_limit=-1 bin/magento cache:flush

NOTE: I usually use php -d memory_limit=-1 on my local, so it's up to you to use that or not.

1

This just happened to me. It's probably not the same cause, but it may help anyone with this problem.

I generated an extension on mage2gen.com for 2.3 when I was working on a 2.2.8 installation.

I'm not sure of the ins and outs, but it could be a version mismatch.

0

I apply all the answer But not work. Then i start to check my code, in env.php file i found problem there. So please carefully to apply all the answer .

1
  • 1
    Check module.xml file of your last installed extension. This error generally because of this file only Apr 25, 2019 at 6:09
0

In my case, I missing these install and session in file app/etc/config.php. You should have these part:

'install' => [ 'date' => 'Fri, 23 Jul 2021 01:45:23 +0000' ], 'crypt' => [ 'key' => '446153a5172b98a8bed611cae8606bf6' ], 'session' => [ 'save' => 'files' ],

Hope it helps someone!

0

The reason for this error can be seen in the command output: php -f bin/magento.

This will work for most errors like There are no commands defined in the "..." namespace..


A fairly common cause is an error in xml files e.g. VendorName/ModuleName/etc/config.xml.

For example, this error can be caused by the fact that the group in the module (<group_id>) is named <config>:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <section_id>
            <group_id><!-- <config> will cause an error here -->
                <!-- ... -->
            </group_id>
        </section_id>
    </default>
</config>
0

One of the cases is that you have a problem with di compilation. Try run:

php bin/magento setup:di:compile

It can show an error in some files, fix it, and rerun the command.

This problem should be solved.

0

Run bin/magento install [params]. Work for me!

-2

A simple,

sudo chmod -R 777 magentodirectory/

will help!

1
  • This will allow anyone from any source to upload AND execute any malicious software on your server. Do NOT do this if you want to keep your webshop!
    – Jacques
    Apr 6, 2023 at 7:49

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