24

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.

  • remove the schema_version and then try – Manashvi Birla Sep 14 '15 at 10:40
  • its not working – Yogesh Karodiya Sep 14 '15 at 10:48
  • Try clearing cache on the command line using bin/magento cache:flush from your public folder – Smartie Sep 14 '15 at 11:15
  • Also, schema_version is being removed in the later versions of the beta from what i have heard – Smartie Sep 14 '15 at 11:25
  • this error is also thrown if a module is referenced in config.php but is not installed – roman204 May 30 '17 at 6:52
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

  • can you please explain in detail why we need to run php -f bin/magento setup:upgrade command – Yogesh Karodiya Sep 14 '15 at 13:30
  • Ssh into your server then cd to magento root folder – Renon Stewart Sep 14 '15 at 13:41
  • R.S is there a magento2 official link specifying all these commands. – huzefam Oct 17 '15 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 – amit_game Dec 7 '15 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
  • 1
    Yes in my case this was the problem .. thanks ;) – Adnan Apr 21 '17 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 Bytes Jun 10 at 7:31
  • This solved my issue as well – Hassan Al-Jeshi Jul 30 at 13:14
11

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
    The tl;dr is longer than the initial paragraph... – Stevie G Jan 25 '17 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. – Darren Felton Apr 4 '18 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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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