Skip to content

"Cannot instantiate interface Magento\Framework\Interception\ObjectManager\ConfigInterface" error in integration tests #12844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
schmengler opened this issue Dec 21, 2017 · 9 comments
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@schmengler
Copy link
Contributor

Preconditions

  1. Magento 2.2.1

Steps to reproduce

  1. Create an integration test with the following fixture:
    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
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 21, 2017
@schmengler
Copy link
Contributor Author

schmengler commented Dec 21, 2017

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.

@magento-team
Copy link
Contributor

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

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jan 3, 2018
@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jan 29, 2018
@magento-engcom-team
Copy link
Contributor

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):

The fix will be available with the upcoming patch release.

@djixas
Copy link

djixas commented Apr 1, 2019

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`

@FrancYescO
Copy link

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

@djixas
Copy link

djixas commented Apr 4, 2019

@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

@toniodlab
Copy link

toniodlab commented Apr 24, 2019

@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

@kibbyboi
Copy link

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

@stkrelax
Copy link

stkrelax commented May 28, 2019

@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

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

branch 2.3-develop has it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

8 participants