Magento2: Magento 2.0.4 DI Compilation Breaks CLI Tool

Created on 8 Apr 2016  Â·  19Comments  Â·  Source: magento/magento2

Steps to reproduce

  1. Install Magento 2.0.4 from composer packages
  2. Change application mode to: production
  3. Run bin/magento setup:di:compile-multi-tenant
  4. Attempt using the bin/magento tool

    Failure encountered

Any attempt to run bin/magento fails until one manually removes the var/di/relations.ser file generated by the compile-multi-tenant process:

PHP Fatal error:  Uncaught Error: Cannot instantiate interface Magento\Framework\Filesystem\DriverInterface in /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:73
Stack trace:
#0 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#1 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#2 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'filesystem', 'Magento\\Framewo...')
#3 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array)
#4 /var/www/magento2/vendor/magento/fr in /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 73

Detailed example

root@m2demo:10:00 AM:/var/www/magento2$ bin/magento | head -n1
Magento CLI version 2.0.4
root@m2demo:10:00 AM:/var/www/magento2$ bin/magento setup:di:compile-multi-tenant | sed 's/^.*$//' | tr "\n" . && echo
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
root@m2demo:10:01 AM:/var/www/magento2$ bin/magento
PHP Fatal error:  Uncaught Error: Cannot instantiate interface Magento\Framework\Filesystem\DriverInterface in /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:73
Stack trace:
#0 /var/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#1 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#2 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'filesystem', 'Magento\\Framewo...')
#3 /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Framewo...', Array, Array)
#4 /var/www/magento2/vendor/magento/fr in /var/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 73
root@m2demo:10:02 AM:/var/www/magento2$ ls -1 var/di
plugins.ser
relations.ser
root@m2demo:10:02 AM:/var/www/magento2$ rm -f var/di/relations.ser 
root@m2demo:10:02 AM:/var/www/magento2$ bin/magento | head -n1
Magento CLI version 2.0.4
root@m2demo:10:02 AM:/var/www/magento2$ bin/magento deploy:mode:show
Current application mode: production.
root@m2demo:10:02 AM:/var/www/magento2$
Ready for Work

Most helpful comment

Thanks! I will escalate internally.

All 19 comments

created internal ticket MAGETWO-51699

@davidalger what's your php version? And do you get the same issue when running single-tenant compiler?

Seems related, and might be an easy way to reproduce:

$ php -v
PHP 7.0.5 (cli) (built: Mar 31 2016 06:38:53) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
    with blackfire v1.10.0, https://blackfire.io, by Blackfireio Inc.


$ vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php
PHPUnit 4.1.0 by Sebastian Bergmann.

Configuration read from /Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/dev/tests/unit/phpunit.xml.dist

......EEEEEE........

Time: 118 ms, Memory: 8.00Mb

There were 6 errors:

1) Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab\InventoryTest::testGetFieldValue with data set #0 (99, array('getField'), 'call-method')
PHPUnit_Framework_MockObject_RuntimeException: Class "Magento\CatalogInventory\Api\Data\StockItemInterface" does not exist.

/Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php:270

2) Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab\InventoryTest::testGetFieldValue with data set #1 (NULL, array(), 'default-result')
PHPUnit_Framework_MockObject_RuntimeException: Class "Magento\CatalogInventory\Api\Data\StockItemInterface" does not exist.

/Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php:270

3) Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab\InventoryTest::testGetFieldValue with data set #2 (99, array(), 'default-result')
PHPUnit_Framework_MockObject_RuntimeException: Class "Magento\CatalogInventory\Api\Data\StockItemInterface" does not exist.

/Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php:270

4) Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab\InventoryTest::testGetConfigFieldValue with data set #0 (99, array('getUseConfigField'), 'call-method')
PHPUnit_Framework_MockObject_RuntimeException: Class "Magento\CatalogInventory\Api\Data\StockItemInterface" does not exist.

/Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php:345

5) Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab\InventoryTest::testGetConfigFieldValue with data set #1 (NULL, array(), 'default-result')
PHPUnit_Framework_MockObject_RuntimeException: Class "Magento\CatalogInventory\Api\Data\StockItemInterface" does not exist.

/Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php:345

6) Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Tab\InventoryTest::testGetConfigFieldValue with data set #2 (99, array(), 'default-result')
PHPUnit_Framework_MockObject_RuntimeException: Class "Magento\CatalogInventory\Api\Data\StockItemInterface" does not exist.

/Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php:345

FAILURES!
Tests: 20, Assertions: 51, Errors: 6.

Could you try 7.0.4? There are reports of something breaking with 7.0.5. Not sure who's fault, but 7.0.5 is behaving differently in a way that impacts Magento.

The version I'm running is indeed 7.0.5. @alankent do you know off-hand what RPM I can use to install 7.0.4 readily? The stack setups I'm doing are using remi, which does not have the old versions present yet. I'll see what I can do to test this in 7.0.4

@dsikkema The single-tenant compiler is broken such that the CLI tool will not work. There is an open issue here on GH for that already I believe, and is an error something to do with the area preferences.

@alankent Same result in PHP 7.0.4

$ /usr/local/Cellar/php70/7.0.4/bin/php -v
PHP 7.0.4 (cli) (built: Mar  4 2016 11:25:38) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
    with blackfire v1.10.0, https://blackfire.io, by Blackfireio Inc.

$ /usr/local/Cellar/php70/7.0.4/bin/php vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/magento/module-catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php
PHPUnit 4.1.0 by Sebastian Bergmann.

Configuration read from /Volumes/CaseSensitive/Workspace/m2-zurich/mage2ce/dev/tests/unit/phpunit.xml.dist

......EEEEEE........

Time: 335 ms, Memory: 8.00Mb

There were 6 errors: 

[...same as above when running the test with 7.0.5...]

In fact, the same happens if I run this test with 7.0.3, 7.0.2, 7.0.1 or 7.0.0.
Before each run I do rm -r dev/tests/unit/tmp var/generation var/cache var/page_cache var/di to be on the safe side by the way. Leaving out that step makes no difference in the result though.

It seems like it's an issue in 2.0.4 with PHP7. The same tests succeed if I execute them with PHP 5.6.20.

Thanks! I will escalate internally.

Same here on php7.0.5 using either multi/single tenant more details here

Complemental Information:

  • If you look at var/di/relations.ser you will find an empty serialized string {}
  • and the compile process stops at Marketplace module.

acknowledged

The igbinary implementation breaks as well on 7.0.x

Any workaround for this error?

@degaray The only workaround would be to remove the var/di/relations.ser file after the failed compilation so that the app continues to run. Obviously not a long-term solution since that is effectively nullifying the meta-data caching intended to speed up performance.

Is there an update on this? My guess the root cause lies in the serialize implementation changes in PHP 7

I had the same issue when running on php 7.0.5 but it works on php 7.0.6

I can confirm that it works for 7.0.6 (both igbinary and standard serializer)

Had this same issue with PHP 7.0.5 and Magento 2.0.6, removing var/di/relations.ser brought back the application.

I can confirm this works in 7.0.6 as well… so since it didn't turn out to be a real bug in Magento (which now officially does not support 7.0.5 specifically) I'm going to close this.

For any future readers: If you are running PHP 7.0.5 and having issues, upgrade to PHP 7.0.6 or better! :)

Magneto 2.1.0 & php7.0.22 - don't work

Was this page helpful?
0 / 5 - 0 ratings