Magento2: sampledata:deploy/remove when custom module located app/code has no composer.json

Created on 23 May 2016  路  4Comments  路  Source: magento/magento2

Steps to reproduce

  1. Install Magento
  2. Create a custom module (without composer file).
  3. Try installing the sample data (bin/magento sampledata:deploy)

[ErrorException]
file_get_contents([path]/app/code/[Vendor]/[ModuleName]/composer.json): failed to open stream: No such file or directory

Although in most cases you would have a composer file it seems a trivial task to just check if the composer file exists in app/code/Magento/SampleData/Model/Dependency.php

Happy to send a pull request if this is not intended behaviour to force people to create composer files though

needs update

Most helpful comment

I'm getting a similar error when running magento sampledata:deploy on Magento 2.1.1:

 [Exception]
  Warning: file_get_contents(path/to/app/code/Vendor/SomeModule/composer.json): failed to open stream: No such file or directory in path/to/vendor/magento/module-sample-data/Model/Dependency.php on line 109

The only solution I could find was https://mage2.pro/t/topic/327.

UPDATE: I just applied the patch from above and can confirm that it works :). The only difference is I modified this file: vendor/magento/module-sample-data/Model/Dependency.php.

All 4 comments

Hello! Please, provide the used version. If the problem is actual for a specific branch, please, specify it and be sure that the latest update was used.

According to contributor guide, tickets without response for two weeks should be closed.
Please feel free to reopen if it's needed.

2.1.1 store, tried to remove sample data, same result:
bin/magento sampledata:remove

Warning: file_get_contents(/home/XXX/www/app/code/Smartwave/Porto/composer.json): failed to open stream: No such file or directory in /home/XXX/www/vendor/magento/module-sample-data/Model/Dependency.php on line 109

I'm getting a similar error when running magento sampledata:deploy on Magento 2.1.1:

 [Exception]
  Warning: file_get_contents(path/to/app/code/Vendor/SomeModule/composer.json): failed to open stream: No such file or directory in path/to/vendor/magento/module-sample-data/Model/Dependency.php on line 109

The only solution I could find was https://mage2.pro/t/topic/327.

UPDATE: I just applied the patch from above and can confirm that it works :). The only difference is I modified this file: vendor/magento/module-sample-data/Model/Dependency.php.

Was this page helpful?
0 / 5 - 0 ratings