25

I installed a local copy of Magento 2. I am facing some problem with custom module.

I followed following file/folder structure

app/code/Ps/HelloWorld/etc/module.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Ps_HelloWorld" schema_version="0.0.1" setup_version="0.0.1" />
</config>

Inside this file I have the following: I refreshed the store cache and then I got:

Setup version for module 'Ps_HelloWorld' is not specified.

5
  • remove the schema_version and then try Commented Sep 14, 2015 at 10:40
  • its not working Commented Sep 14, 2015 at 10:48
  • Try clearing cache on the command line using bin/magento cache:flush from your public folder
    – Smartie
    Commented Sep 14, 2015 at 11:15
  • Also, schema_version is being removed in the later versions of the beta from what i have heard
    – Smartie
    Commented Sep 14, 2015 at 11:25
  • this error is also thrown if a module is referenced in config.php but is not installed
    – roman204
    Commented May 30, 2017 at 6:52

8 Answers 8

15

Try

php -f bin/magento module:enable --clear-static-content Module_Name
php -f bin/magento setup:upgrade

Assuming that you are run the current master branch and not dev branch

5
  • can you please explain in detail why we need to run php -f bin/magento setup:upgrade command Commented Sep 14, 2015 at 13:30
  • Ssh into your server then cd to magento root folder Commented Sep 14, 2015 at 13:41
  • R.S is there a magento2 official link specifying all these commands.
    – huzefam
    Commented Oct 17, 2015 at 17:27
  • 2
    you can get list of all commands by runnning php -f bin/magento, either it will also provide what is the purpose of each and every command Commented Dec 7, 2015 at 8:30
33

In my case it was the file/folder permission of that module.

Apache couldn't read the configuration file.

Apply following permission to your module directory.

chmod 775 <module path> -R
3
  • 1
    Yes in my case this was the problem .. thanks ;)
    – Adnan
    Commented Apr 21, 2017 at 7:56
  • After a huge search, i had saw this answer and tried as a final try. Oh my god, my issue get solved. Thank you so much @Nahid Bro :)
    – Ask Xah
    Commented Jun 10, 2019 at 7:31
  • This solved my issue as well Commented Jul 30, 2019 at 13:14
13

Reference source: https://magentoexplorer.com/magento-2-setup-version-for-module-is-not-specified-how-to-fix (in my case, i got this error when creating a new Magento 2 module)

You may encounter this error because of wrong module file/folder permission, you can change permission for module folder as follow

chmod 775 <module path> -R

There's another possibility that you forgot to add registration.php and composer.json in module. Try to add the following file

/app/code/Namespace/Module/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Namespace_Module',
    __DIR__
);

and /app/code/Namespace/Module/composer.json

{
    "name": "namespace/module",
    "description": "namespace",
    "require": {
      "php": "~5.5.0|~5.6.0|~7.0.0",
      "magento/framework": "100.0.*",
      "magento/module-ui": "100.0.*",
      "magento/module-config": "100.0.*",
      "magento/module-contact": "100.0.*"    
    },
    "type": "magento2-module",
    "version": "100.0.0",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "extra": {
        "map": [
            [
                "*",
                "Namespace/Module"
            ]
        ]
    },
    "autoload": {
        "files": [ "registration.php" ],
        "psr-4": {
            "namespace\\module\\": ""
        }
    }
}

Finally run these commands

php -f bin/magento module:enable --clear-static-content Module_Name
magento setup:upgrade

Hope this helps!

4

An additional scenario where this has come up for me was due to performing a pull on my project's repository and the module had been removed from the file system. While this was intentional, there remained at the time lingering configuration for it in Magento's configuration file.

Removing the reference to the module from app/etc/config.php resolved my issue.

TL;DR

I did first try disabling the module using the CLI's module:disable VendorName_ModuleName command and the response back from the CLI was Unknown module(s): 'VendorName_ModuleName'. I assume this is because it was already missing from the file system. Since there weren't intentions of using the module ever again, manual removal of it from app/etc/config.php at this point seems appropriate anyway.

2
  • 2
    The tl;dr is longer than the initial paragraph...
    – tread
    Commented Jan 25, 2017 at 12:13
  • 1
    @StevieG I still smile every time I come back to this hahahaha... When I first wrote this I did not know what TL;DR meant I believe. That the "tl;dr" portion is additional info that is intended to be skipped if you so choose or something. Commented Apr 4, 2018 at 0:50
1

Open your Database and find the table setup_module.

Your module Ps_HelloWorld should be in this table.

If not found try to enter manually.

1

I had this same problem and it was because PHP Opcache was enabled and based on my settings any updates to any PHP file did not get updated in the cache.

You can clear opcache by creating a file clear_opcache.php and enter the code below.

<?php
opcache_reset();
?>

Then you can run

php clear_opcache.php

Or in my case I can restart the php-fpm service for RHEL

Centos/RHEL 7

systemctl restart php-fpm

Centos/RHEL 6 or older

service php-fpm restart

You can find other ways to restart php-fpm here https://www.cyberciti.biz/faq/how-to-reload-restart-php7-0-fpm-service-linux-unix/

0

Problem : the file app/etc/config.php was copied from another magento instance (because of a bad file manipulation). Because of that, I had the same symptoms than described in this question.

The solution was to delete all modules names that wasn't in the instance of Magento where the problem occured, and it worked out fine.

Note that a better solution would have probably been to bin/magento module:status , and then bin/magento module:disable for all the module with problems.

0

I faced same issue. My setup was through docker, doing php container down, then up cleared cache and resolved the issue.

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.