module-blog icon indicating copy to clipboard operation
module-blog copied to clipboard

Fatal error while installing the module: Cannot instantiate interface Magefan\\Blog\\Api\\CategoryRepositoryInterface

Open xgerhard opened this issue 2 years ago • 5 comments

Describe the bug

Fatal error while installing the Blog module:

"Fatal Error: 'Uncaught Error: Cannot instantiate interface Magefan\\Blog\\Api\\CategoryRepositoryInterface in \/home\/X\/domains\/X.nl\/application\/vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:50

Stack trace:
#0 \/home\/X\/domains\/X.nl\/application\/vendor\/magento\/framework\/ObjectManager\/ObjectManager.php(56): 
Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create('Magefan\\\\Blog\\\\Ap...', Array)
#1 \/home\/X\/domains\/X.nl\/application\/vendor\/magefan\/module-blog\/Model\/ResourceModel\/Post\/Collection.php(68): 
Magento\\Framework\\ObjectManager\\ObjectManager->create('Magefan\\\\Blog\\\\Ap...')
#2 \/home\/X\/domains\/X.nl\/application\/generated\/code\/Magefan\/Blog\/Model\/ResourceModel\/Post\/Collection\/Interceptor.php(14): 
Magefan\\Blog\\Model\\ResourceModel\\Post\\Collection->__construct(Object(Magento\\Framework\\Data\\Collection\\EntityFactory), Object(Magento\\Framework\\Logger\\LoggerProxy), Object(Magento\\Framework\\Data\\Collection\\Db\\FetchStrategy\\Query), ' in '\/home\/X\/domains\/X.nl\/application\/vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php' on line 50"

Preconditions:

  • Magento Version: 2.4.2
  • Module Version: 2.10.10.2
  • PHP Version 7.3.33

To Reproduce Steps to reproduce the behavior:

  1. Run composer require magefan/module-blog
  2. Run php bin/magento setup:upgrade

Expected behavior No errors

Actual behavior Fatal error as shown above

Not sure if it's related to other 3rd party extensions, hopefully you guys can point me in the right direction of finding the cause.

xgerhard avatar Sep 28 '22 12:09 xgerhard

@xgerhard ,

Please run the command

bin/magento setup:di:compile

Let us know if it helps.

magefan avatar Sep 28 '22 12:09 magefan

Ah thanks, that should be run before setup:upgrade? I'll try this tomorrow.

xgerhard avatar Sep 28 '22 13:09 xgerhard

@xgerhard, usualy it runs after. But try to run before. For some reason, the implementing class of the interface was not assigned.

magefan avatar Sep 28 '22 13:09 magefan

Unfortunately the same error. I'll see if I can get more info, on a different instance with same Magento version it did work fine.

xgerhard avatar Sep 29 '22 08:09 xgerhard

Try to run this commands

rm -rf generated rm -rf var/cache #if has redis flush redis cache bin/magento setup:di:compile

magefan avatar Sep 29 '22 10:09 magefan

Well... was about to try steps above, but tried the 'normal' way again first: 1. require.., 2. setup:upgrade , 3. di:compile. This time it ran without any errors, so it indeed might have been some cache related issue. Thanks for the suggestions!

xgerhard avatar Oct 03 '22 14:10 xgerhard