Magento2: "Cannot instantiate interface Magento\Framework\Interception\ObjectManager\ConfigInterface" error in integration tests

Created on 21 Dec 2017  路  9Comments  路  Source: magento/magento2


Preconditions

  1. Magento 2.2.1

Steps to reproduce

  1. Create an integration test with the following fixture:
    php protected function setUp() { $this->objectManager = Bootstrap::getObjectManager(); $this->commandList = $this->objectManager->create(CommandListInterface::class); }

    Expected result

  1. I can use the command list to test registered commands

Actual result

  1. The test fails with an error like this:
    Cannot instantiate interface Magento\Framework\Interception\ObjectManager\ConfigInterface PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50 PATH/vendor/magento/framework/ObjectManager/ObjectManager.php:70 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59 PATH/vendor/magento/framework/ObjectManager/ObjectManager.php:70 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59 PATH/vendor/magento/framework/ObjectManager/ObjectManager.php:70 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59 PATH/vendor/magento/framework/ObjectManager/ObjectManager.php:70 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:180 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:156 PATH/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34 PATH/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59 PATH/vendor/magento/framework/ObjectManager/ObjectManager.php:56 PATH/vendor/example/example/tests/ExampleTest.php:53

I logged which classes were instantiated befor the error and it seems like XmlCatalogGenerateCommand has the object manager config in its dependency graph, but in the integration test environment there is no preference for it.

Magento\Developer\Console\Command\XmlCatalogGenerateCommand
=> Magento\Framework\App\Utility\Files
=> Magento\Framework\Component\DirSearch
=> Magento\Framework\App\Utility\RegexIteratorFactory
=> Magento\Developer\Model\XmlCatalog\Format\PhpStorm
=> Magento\Framework\Filesystem\File\WriteFactory
=> Magento\Developer\Console\Command\DiInfoCommand
=> Magento\Developer\Model\Di\Information
=> Magento\Developer\Model\Di\PluginList
=> Magento\Framework\Interception\ObjectManager\ConfigInterface
Fixed in 2.2.x Fixed in 2.3.x Format is valid

Most helpful comment

@FrancYescO & @djixas , I just fixed it :

1/ Add the following line into /app/etc/di.xml file :

<preference for="Magento\Framework\HTTP\ClientInterface" type="Magento\Framework\HTTP\Client\Curl" />

2/ Create a new module, with the following /etc/di.xml file :

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Framework\HTTP\ClientInterface" type="Magento\Framework\HTTP\Client\Curl" />
</config>

3/ With command line : php bin/magento setup:di:compile, then php bin/magento setup:upgrade

4/ Remove the line added in 1/ (in /app/etc/di.xml)

5/ With command line : php bin/magento setup:di:compile, then php bin/magento setup:upgrade

This should be fixed

All 9 comments

I worked around this issue by adding the preference manually in my test:

$this->objectManager->configure(
    [
        'preferences' => [
            ltrim(
                \Magento\Framework\Interception\ObjectManager\ConfigInterface::class,
                '\\'
            ) => ltrim(
                \Magento\TestFramework\ObjectManager\Config::class,
                '\\'
            ),
        ],
    ]
);

But that should not be necessary.

Hi @schmengler. Thank you for your report.
The issue has been fixed in magento/magento2#12845 by @schmengler in 2.2-develop branch
Related commit(s):

  • 50ffc6ac185ac8c9e6f95f0e60ec7a3d510e743b

The fix will be available with the upcoming patch release.

Hi @schmengler. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1299 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

  • 99e3a76b47267c930d4268b7bbf65500d1913f24
  • 4cfc07e28a8edb388011168e5fd0726dc6c71119
  • ea616e0a217e74707305f1038e6ca207d4bdaba6
  • be55217eae883abd02d44211fa0a88bb0a1d803c
  • 41c52fb989d961ad6ac48eea23163deb61dd9adc
  • 7f42a672ee864f2fc186d0259eb0de2e3d9634f6
  • 1090c8b54733b409a17553bfeb3ec292d449e5ce
  • c80b5ca54d2890407cf329bd24312ebf858929d2
  • 8077af7d42d069523f4addc21741567579e6e74f
  • 38e34a8747651b69a85575d7416d88a3ae49a34d
  • c13ad8595cf555b683223688325fe888fc112bec
  • 9e7bf93ec5b0e90952cac07391d2bde1a72d81ef
  • 10a6288175601ba26075996f3c39880b6e17eb76
  • abf31d2afaa543cddca00b197434ba3f28ac199b
  • 898a470a8b8b6cc6048a403be03594b8fd1b6b98
  • c99c3a7ae67ab16ab2407641a9b2c796f63ce3ef
  • 4537e784c70a3e07470ff7424684348c802839c8
  • 0bad56f0c371d5edc3cfc80dbae1e11400516546
  • fd2418ed8d062181ebc2e10bc298aba95d6d7a5e
  • 946e9e1b508e7788abf12e5c50098cdd9f6447ec

The fix will be available with the upcoming patch release.

Same error exists in 2.3.1, fresh install, after not installing all modules, error 500 in admin panel of products page, all other pages load fine,

Not sure what not installed module is causing the error

`[root@host /home/x/public_html]# php bin/magento setup:upgrade

Fatal error: Uncaught Error: Cannot instantiate interface Magento\Framework\HTTP\ClientInterface in /home/x/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50
Stack trace:

0 /home/x/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Framewo...')

1 /home/x/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(160): Magento\Framework\ObjectManager\ObjectManager->get('Magento\Framewo...')

2 /home/x/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(246): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\Framewo...', NULL, 'client', 'Magento\Invento...')

3 /home/x/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\Invento...', Array, in /home/x/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 50`

@djixas have you fixed? i'm having same error on 2.3.1

@FrancYescO

I did, will stay with v1.9 for foreseeable future and then migrate to a store that does not take 20 seconds to load without 50 cache modules enabled

@FrancYescO & @djixas , I just fixed it :

1/ Add the following line into /app/etc/di.xml file :

<preference for="Magento\Framework\HTTP\ClientInterface" type="Magento\Framework\HTTP\Client\Curl" />

2/ Create a new module, with the following /etc/di.xml file :

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Framework\HTTP\ClientInterface" type="Magento\Framework\HTTP\Client\Curl" />
</config>

3/ With command line : php bin/magento setup:di:compile, then php bin/magento setup:upgrade

4/ Remove the line added in 1/ (in /app/etc/di.xml)

5/ With command line : php bin/magento setup:di:compile, then php bin/magento setup:upgrade

This should be fixed

I have this issue after i upgrade my magento to 2.3.1 , can someone help me to resolve it . Thank you

Fatal error: Uncaught Error: Cannot instantiate interface Magento\Framework\Acl\LoaderInterface in /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:116 Stack trace: #0 /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Framewo...', Array) #1 /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...') #2 /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...') #3 /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...') #4 /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Fram in /home/edgeexpr/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 116

@djixas
module-ups
and
module-inventory-distance-based-source-selection

have the use Magento\Framework\HTTP\ClientInterface;

@toniodlab
fixed the problem

tag 2.3.1 is missing the
```xml

````

branch 2.3-develop has it

Was this page helpful?
0 / 5 - 0 ratings