0

I ran into this while building a custom module

Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory.

When running this command I got another issue:

There are no commands defined in the setup namespace

Is this a know issue or did I something wrong? Thanks

*****EDIT****

app/code/Unreal/Custom/etc/module.xml

<?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="Unreal_Custom" schema_version="2.0.0" setup_version="0.0.2">
    </module>
</config>

app/code/Unreal/Custom/registration.php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Unreal_Custom',
    __DIR__
);
9
  • You should set permission 777 for var and pub folder again
    – LinoPham
    Nov 23, 2015 at 16:21
  • this does not fix it , sorry
    – xhallix
    Nov 23, 2015 at 16:39
  • 1
    Can you add the folder/file structure for your module, assuming that setup:upgrade work when your module is removed then the issue lies within your module Nov 23, 2015 at 16:50
  • Have you installed Magento 2 already?
    – mbalparda
    Nov 23, 2015 at 17:05
  • 1
    schema_version is no longer used, please use just setup_version. Also, we no longer hardcode the path to the schema, URNs are used. Please see example here: github.com/magento/magento2/blob/develop/app/code/Magento/… Also, can you run the upgrade command again with -vvv flag. It should show stack trace if you are in developer mode.
    – Maddy
    Nov 24, 2015 at 23:14

5 Answers 5

2

There are no commands defined is a generic message which hides a real problem. Usially the real problem is an error in a module.xml file or a composer.json file: https://github.com/magento/magento2/issues/2300
https://magento.stackexchange.com/a/91097

0

You have this error, because magento can't initialize all commands. Error in your custom module. Try temporary remove it.

3
  • but I want to add a custom module :) So what to do in this case?
    – xhallix
    Nov 23, 2015 at 16:37
  • I think issue with xml files. You should validate files etc/confix.xml di.xml module.xml etc
    – Alex
    Nov 23, 2015 at 17:53
  • just updated the xml in this question
    – xhallix
    Nov 24, 2015 at 8:55
0

i hope you dint set php in env variable,

  • open cmd
  • cd xampp/php
  • php prject_fullPath\Project_folder\bin\magento setup:upgrade

this in my localhost , if your in server go to php folder and run the command with full path

1
  • this returns the error message There are no commands defined in the setup namespace
    – xhallix
    Nov 24, 2015 at 9:10
0

i hope hen issue is in composer.json or module.xml below are the 3 imp file make sure all correct

etc/module.xml

<?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="Sugarcode_Test" setup_version="2.0.6" schema_version="2.0.6">
        <sequence>
            <module name="Magento_Checkout"/>
        </sequence>
    </module>
</config>

composer.json

{
    "name": "sugarcode/module-test",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0"
    },
    "type": "magento2-module",
    "version": "100.0.2",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ],
        "psr-4": {
            "Sugarcode\\Test\\": ""
        }
    }
}

and app\code\Sugarcode\Test\registration.php

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Sugarcode_Test',
    __DIR__
);
1
  • 1
    Please remove schema_version. It is no longer used. Also, schemas are now specified via URNs
    – Maddy
    Nov 24, 2015 at 23:15
0

I have faced the same issue and figure out the issue. I am posting this, hoping it may help others.
Actually in my case the problem was the php system environment variable was not set.
Go to system environment variable add your php location to path, in my case ";D:\xampp\php".
Or go to your terminal and go to bin folder inside magento root directory and run the script mentioned above.

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.